Skip to content

Commit

Permalink
Fix pyright test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Apr 18, 2022
1 parent fd2a62c commit a4dd971
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
RELEASE_TYPE: patch

Updated the type annotations for :func:`@given <hypothesis.given>` so that
type-checkers will raise on mixed positional and keyword arguments.
This patch updates the type annotations for :func:`@given <hypothesis.given>`
so that type-checkers will warn on mixed positional and keyword arguments,
as well as fixing :issue:`3296`.
23 changes: 12 additions & 11 deletions whole-repo-tests/test_pyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,17 @@ def test_pyright_raises_for_mixed_pos_kwargs_in_given(tmp_path: Path):
from hypothesis import given
from hypothesis.strategies import text
@given(text(), x=text()) # type: ignore
def test_bar(x):
...
@given(text(), x=text())
def test_bar(x: str):
pass
"""
)
)
_write_config(
tmp_path,
{
"typeCheckingMode": "strict",
"reportUnnecessaryTypeIgnoreComment": "true",
},
_write_config(tmp_path, {"typeCheckingMode": "strict"})
assert any(
e["message"].startswith('No overloads for "given" match the provided arguments')
for e in _get_pyright_errors(file)
)
assert _get_pyright_errors(file) == []


# ---------- Helpers for running pyright ---------- #
Expand All @@ -105,7 +102,11 @@ def _get_pyright_output(file: Path) -> dict[str, Any]:
text=True,
capture_output=True,
)
return json.loads(proc.stdout)
try:
return json.loads(proc.stdout)
except Exception:
print(proc.stdout)
raise


def _get_pyright_errors(file: Path) -> list[dict[str, Any]]:
Expand Down

0 comments on commit a4dd971

Please sign in to comment.