Skip to content

Commit

Permalink
Update typecheck tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Oct 15, 2024
1 parent 7f16667 commit 34b3264
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 31 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch updates some internal type annotations.
4 changes: 0 additions & 4 deletions hypothesis-python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import types
from pathlib import Path

import sphinx_rtd_theme

root = Path(__file__).parent.parent
sys.path.append(str(root / "src"))

Expand Down Expand Up @@ -152,8 +150,6 @@ def setup(app):

html_theme = "sphinx_rtd_theme"

html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

html_static_path = ["_static"]

html_css_files = ["better-signatures.css", "wrap-in-tables.css"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ def ip_addresses(
if v not in (None, network.version):
raise InvalidArgument(f"{v=} is incompatible with {network=}")
addr_type = IPv4Address if network.version == 4 else IPv6Address
return integers(int(network[0]), int(network[-1])).map(addr_type) # type: ignore
return integers(int(network[0]), int(network[-1])).map(addr_type)
2 changes: 1 addition & 1 deletion requirements/tools.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ numpy
pelican[markdown]
pip-tools
pyright
pytest
python-dateutil
requests
restructuredtext-lint
Expand All @@ -28,3 +27,4 @@ types-click
types-pytz
types-redis
typing-extensions
-r test.in
28 changes: 19 additions & 9 deletions requirements/tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
#
alabaster==1.0.0
# via sphinx
anyio==4.6.0
anyio==4.6.2.post1
# via watchfiles
asgiref==3.8.1
# via django
asttokens==2.4.1
# via stack-data
attrs==24.2.0
# via hypothesis (hypothesis-python/setup.py)
attrs==24.1.0
# via
# -r requirements/test.in
# hypothesis (hypothesis-python/setup.py)
autoflake==2.3.1
# via shed
babel==2.16.0
Expand Down Expand Up @@ -48,7 +50,7 @@ colorama==0.4.6
# via tox
com2ann==0.3.0
# via shed
coverage==7.6.2
coverage==7.6.3
# via -r requirements/tools.in
cryptography==43.0.1
# via
Expand Down Expand Up @@ -77,6 +79,8 @@ exceptiongroup==1.2.2 ; python_version < "3.11"
# hypothesis (hypothesis-python/setup.py)
# ipython
# pytest
execnet==2.1.1
# via pytest-xdist
executing==2.1.0
# via stack-data
feedgenerator==2.1.0
Expand Down Expand Up @@ -141,7 +145,7 @@ more-itertools==10.5.0
# via
# jaraco-classes
# jaraco-functools
mypy==1.11.2
mypy==1.12.0
# via -r requirements/tools.in
mypy-extensions==1.0.0
# via
Expand Down Expand Up @@ -170,7 +174,9 @@ pathspec==0.12.1
pelican[markdown]==4.10.1
# via -r requirements/tools.in
pexpect==4.9.0
# via ipython
# via
# -r requirements/test.in
# ipython
pip-tools==7.4.1
# via -r requirements/tools.in
pkginfo==1.10.0
Expand Down Expand Up @@ -210,7 +216,11 @@ pyproject-hooks==1.2.0
pyright==1.1.384
# via -r requirements/tools.in
pytest==8.3.3
# via -r requirements/tools.in
# via
# -r requirements/test.in
# pytest-xdist
pytest-xdist==3.6.1
# via -r requirements/test.in
python-dateutil==2.9.0.post0
# via
# -r requirements/tools.in
Expand Down Expand Up @@ -260,7 +270,7 @@ sortedcontainers==2.4.0
# via hypothesis (hypothesis-python/setup.py)
soupsieve==2.6
# via beautifulsoup4
sphinx==8.1.2
sphinx==8.1.3
# via
# -r requirements/tools.in
# sphinx-codeautolink
Expand Down Expand Up @@ -328,7 +338,7 @@ types-pytz==2024.2.0.20241003
# via -r requirements/tools.in
types-redis==4.6.0.20241004
# via -r requirements/tools.in
types-setuptools==75.1.0.20240917
types-setuptools==75.1.0.20241014
# via types-cffi
typing-extensions==4.12.2
# via
Expand Down
2 changes: 1 addition & 1 deletion tooling/src/hypothesistooling/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def check_whole_repo_tests(*args):
)

if not args:
args = [tools.REPO_TESTS]
args = ["-n", "auto", tools.REPO_TESTS]
subprocess.check_call([sys.executable, "-m", "pytest", *args])


Expand Down
6 changes: 6 additions & 0 deletions whole_repo_tests/revealed_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.

import re

from hypothesistooling.__main__ import PYTHONS as pythons_map

PYTHON_VERSIONS = [v for v in pythons_map if re.fullmatch(r"3\.\d\d?", v)]

try:
from numpy import __version__ as np_version
except ImportError:
Expand Down
4 changes: 1 addition & 3 deletions whole_repo_tests/test_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
from hypothesistooling.projects.hypothesispython import PYTHON_SRC
from hypothesistooling.scripts import pip_tool, tool_path

from .revealed_types import NUMPY_REVEALED_TYPES, REVEALED_TYPES

PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
from .revealed_types import NUMPY_REVEALED_TYPES, PYTHON_VERSIONS, REVEALED_TYPES


def test_mypy_passes_on_hypothesis():
Expand Down
16 changes: 4 additions & 12 deletions whole_repo_tests/test_pyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
from hypothesistooling.projects.hypothesispython import HYPOTHESIS_PYTHON, PYTHON_SRC
from hypothesistooling.scripts import pip_tool, tool_path

from .revealed_types import NUMPY_REVEALED_TYPES, REVEALED_TYPES

PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
from .revealed_types import NUMPY_REVEALED_TYPES, PYTHON_VERSIONS, REVEALED_TYPES


@pytest.mark.skip(
Expand Down Expand Up @@ -83,15 +81,9 @@ def f():
_write_config(
tmp_path, {"typeCheckingMode": "strict", "pythonVersion": python_version}
)
assert (
sum(
e["message"].startswith(
'Argument of type "Literal[1]" cannot be assigned to parameter "_given_arguments"'
)
for e in _get_pyright_errors(file)
)
== 1
)
errors = _get_pyright_errors(file)
msg = 'Argument of type "Literal[1]" cannot be assigned to parameter "_given_arguments"'
assert sum(e["message"].startswith(msg) for e in errors) == 1, errors


def test_pyright_issue_3296(tmp_path: Path):
Expand Down

0 comments on commit 34b3264

Please sign in to comment.