Skip to content

Commit

Permalink
add pyright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsokl committed Apr 18, 2022
1 parent 6752293 commit 0930f9e
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion whole-repo-tests/test_pyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,45 @@ def test_bar(x: str):
assert _get_pyright_errors(file) == []


def test_pyright_issue_3296(tmp_path: Path):
file = tmp_path / "test.py"
file.write_text(
textwrap.dedent(
"""
from hypothesis.strategies import lists, integers
reveal_type(lists(integers()).map(sorted), expected_text="SearchStrategy[list[int]]")
"""
)
)
_write_config(tmp_path, {"typeCheckingMode": "strict"})
assert _get_pyright_errors(file) == []


def test_pyright_raises_for_mixed_pos_kwargs_in_given(tmp_path: Path):
file = tmp_path / "test.py"
file.write_text(
textwrap.dedent(
"""
from hypothesis import given
from hypothesis.strategies import text
@given(text(), x=text()) # type: ignore
def test_bar(x):
...
"""
)
)
_write_config(
tmp_path,
{
"typeCheckingMode": "strict",
"reportUnnecessaryTypeIgnoreComment": "true",
},
)
assert _get_pyright_errors(file) == []


# ---------- Helpers for running pyright ---------- #


Expand All @@ -63,7 +102,7 @@ def _get_pyright_output(file: Path) -> dict[str, Any]:
[tool_path("pyright"), "--outputjson"],
cwd=file.parent,
encoding="utf-8",
universal_newlines=True,
text=True,
capture_output=True,
)
return json.loads(proc.stdout)
Expand Down

0 comments on commit 0930f9e

Please sign in to comment.