Skip to content

Commit a4dd971

Browse files
committed
Fix pyright test
1 parent fd2a62c commit a4dd971

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
RELEASE_TYPE: patch
22

3-
Updated the type annotations for :func:`@given <hypothesis.given>` so that
4-
type-checkers will raise on mixed positional and keyword arguments.
3+
This patch updates the type annotations for :func:`@given <hypothesis.given>`
4+
so that type-checkers will warn on mixed positional and keyword arguments,
5+
as well as fixing :issue:`3296`.

whole-repo-tests/test_pyright.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,17 @@ def test_pyright_raises_for_mixed_pos_kwargs_in_given(tmp_path: Path):
7878
from hypothesis import given
7979
from hypothesis.strategies import text
8080
81-
@given(text(), x=text()) # type: ignore
82-
def test_bar(x):
83-
...
81+
@given(text(), x=text())
82+
def test_bar(x: str):
83+
pass
8484
"""
8585
)
8686
)
87-
_write_config(
88-
tmp_path,
89-
{
90-
"typeCheckingMode": "strict",
91-
"reportUnnecessaryTypeIgnoreComment": "true",
92-
},
87+
_write_config(tmp_path, {"typeCheckingMode": "strict"})
88+
assert any(
89+
e["message"].startswith('No overloads for "given" match the provided arguments')
90+
for e in _get_pyright_errors(file)
9391
)
94-
assert _get_pyright_errors(file) == []
9592

9693

9794
# ---------- Helpers for running pyright ---------- #
@@ -105,7 +102,11 @@ def _get_pyright_output(file: Path) -> dict[str, Any]:
105102
text=True,
106103
capture_output=True,
107104
)
108-
return json.loads(proc.stdout)
105+
try:
106+
return json.loads(proc.stdout)
107+
except Exception:
108+
print(proc.stdout)
109+
raise
109110

110111

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

0 commit comments

Comments
 (0)