From c9d473b05a1cdcd9d04185ee4fb4b86e1e5f08e3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 10 Jan 2023 13:33:06 -0500 Subject: [PATCH] mypy: install pytest alongside mypy to get its types --- requirements/mypy.in | 3 ++ requirements/mypy.pip | 89 ++++++++++++++++++++++++++++++++++++++++++- tests/mixins.py | 8 ++-- tests/test_oddball.py | 1 + tests/test_venv.py | 2 +- 5 files changed, 96 insertions(+), 7 deletions(-) diff --git a/requirements/mypy.in b/requirements/mypy.in index 50828014b..871c589c3 100644 --- a/requirements/mypy.in +++ b/requirements/mypy.in @@ -3,4 +3,7 @@ -c pins.pip +# So that we have pytest types. +-r pytest.pip + mypy diff --git a/requirements/mypy.pip b/requirements/mypy.pip index 6ea7438c5..d36cf2d4b 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -4,6 +4,51 @@ # # make upgrade # +attrs==22.2.0 \ + --hash=sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836 \ + --hash=sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99 + # via + # -r requirements/pytest.pip + # hypothesis + # pytest +colorama==0.4.6 \ + --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ + --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 + # via -r requirements/pytest.pip +exceptiongroup==1.1.0 \ + --hash=sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e \ + --hash=sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23 + # via + # -r requirements/pytest.pip + # hypothesis + # pytest +execnet==1.9.0 \ + --hash=sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5 \ + --hash=sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142 + # via + # -r requirements/pytest.pip + # pytest-xdist +flaky==3.7.0 \ + --hash=sha256:3ad100780721a1911f57a165809b7ea265a7863305acb66708220820caf8aa0d \ + --hash=sha256:d6eda73cab5ae7364504b7c44670f70abed9e75f77dd116352f662817592ec9c + # via -r requirements/pytest.pip +hypothesis==6.62.0 \ + --hash=sha256:76f1141e8237f6dd0780a171bec5d6aec873208ccc27b5f9753d4cccd8904272 \ + --hash=sha256:e250da77878460f74b53039493a7a18d6fc137b0b77791b382b6a0f4ada9144e + # via -r requirements/pytest.pip +importlib-metadata==6.0.0 \ + --hash=sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad \ + --hash=sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d + # via + # -r requirements/pytest.pip + # pluggy + # pytest +iniconfig==2.0.0 \ + --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ + --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 + # via + # -r requirements/pytest.pip + # pytest mypy==0.991 \ --hash=sha256:0714258640194d75677e86c786e80ccf294972cc76885d3ebbb560f11db0003d \ --hash=sha256:0c8f3be99e8a8bd403caa8c03be619544bc2c77a7093685dcf308c6b109426c6 \ @@ -40,10 +85,41 @@ mypy-extensions==0.4.3 \ --hash=sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d \ --hash=sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8 # via mypy +packaging==23.0 \ + --hash=sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2 \ + --hash=sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97 + # via + # -r requirements/pytest.pip + # pytest +pluggy==1.0.0 \ + --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ + --hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3 + # via + # -r requirements/pytest.pip + # pytest +pytest==7.2.0 \ + --hash=sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71 \ + --hash=sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59 + # via + # -r requirements/pytest.pip + # pytest-xdist +pytest-xdist==3.1.0 \ + --hash=sha256:40fdb8f3544921c5dfcd486ac080ce22870e71d82ced6d2e78fa97c2addd480c \ + --hash=sha256:70a76f191d8a1d2d6be69fc440cdf85f3e4c03c08b520fd5dc5d338d6cf07d89 + # via -r requirements/pytest.pip +sortedcontainers==2.4.0 \ + --hash=sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88 \ + --hash=sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0 + # via + # -r requirements/pytest.pip + # hypothesis tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f - # via mypy + # via + # -r requirements/pytest.pip + # mypy + # pytest typed-ast==1.5.4 \ --hash=sha256:0261195c2062caf107831e92a76764c81227dae162c4f75192c0d489faf751a2 \ --hash=sha256:0fdbcf2fef0ca421a3f5912555804296f0b0960f0418c440f5d6d3abb549f3e1 \ @@ -73,4 +149,13 @@ typed-ast==1.5.4 \ typing-extensions==4.4.0 \ --hash=sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa \ --hash=sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e - # via mypy + # via + # -r requirements/pytest.pip + # importlib-metadata + # mypy +zipp==3.11.0 \ + --hash=sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa \ + --hash=sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766 + # via + # -r requirements/pytest.pip + # importlib-metadata diff --git a/tests/mixins.py b/tests/mixins.py index d207f7798..c8f79d675 100644 --- a/tests/mixins.py +++ b/tests/mixins.py @@ -14,7 +14,7 @@ import os.path import sys -from typing import Any, Callable, Iterable, Iterator, Optional, Tuple +from typing import Any, Callable, Iterable, Iterator, Optional, Tuple, cast import pytest @@ -138,12 +138,12 @@ def _capcapsys(self, capsys: pytest.CaptureFixture[str]) -> None: def stdouterr(self) -> Tuple[str, str]: """Returns (out, err), two strings for stdout and stderr.""" - return self.capsys.readouterr() # type: ignore[no-any-return] + return cast(Tuple[str, str], self.capsys.readouterr()) def stdout(self) -> str: """Returns a string, the captured stdout.""" - return self.capsys.readouterr().out # type: ignore[no-any-return] + return self.capsys.readouterr().out def stderr(self) -> str: """Returns a string, the captured stderr.""" - return self.capsys.readouterr().err # type: ignore[no-any-return] + return self.capsys.readouterr().err diff --git a/tests/test_oddball.py b/tests/test_oddball.py index a44beae48..23e3ce9d0 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -209,6 +209,7 @@ def test_dropping_none(self) -> None: # pragma: not covered pytest.skip("This is too expensive for now (30s)") # Start and stop coverage thousands of times to flush out bad # reference counting, maybe. + _ = "this is just here to put a type comment on" # type: ignore[unreachable] self.make_file("the_code.py", """\ import random def f(): diff --git a/tests/test_venv.py b/tests/test_venv.py index eb4ed5c0a..de7ebbe18 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -48,7 +48,7 @@ def venv_world_fixture(tmp_path_factory: pytest.TempPathFactory) -> Path: Returns the directory containing the "venv" virtualenv. """ - venv_world = cast(Path, tmp_path_factory.mktemp("venv_world")) + venv_world = tmp_path_factory.mktemp("venv_world") with change_dir(venv_world): # Create a virtualenv. run_command("python -m venv venv")