From 0930f9eb78131b4e0ef26e3503b6ebd86b072aa8 Mon Sep 17 00:00:00 2001 From: Ryan Soklaski Date: Sun, 17 Apr 2022 20:01:14 -0400 Subject: [PATCH] add pyright tests --- whole-repo-tests/test_pyright.py | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/whole-repo-tests/test_pyright.py b/whole-repo-tests/test_pyright.py index 6f44fc6f6b..2b41c39a56 100644 --- a/whole-repo-tests/test_pyright.py +++ b/whole-repo-tests/test_pyright.py @@ -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 ---------- # @@ -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)