From 0da2d13063d65e54004153286a424a29dd3c1d95 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Sun, 11 Aug 2024 11:56:14 -0700 Subject: [PATCH] Require mypy >= 1.0 --- pyproject.toml | 2 +- tests/test_pytest_mypy.py | 43 +-------------------------------------- tox.ini | 29 +++++++++++--------------- 3 files changed, 14 insertions(+), 60 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 983fe8e..3a5c72b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ requires-python = ">=3.7" dependencies = [ "attrs>=19.0", "filelock>=3.0", - "mypy>=0.50", + "mypy>=1.0", "pytest>=4.6", ] diff --git a/tests/test_pytest_mypy.py b/tests/test_pytest_mypy.py index 03d2b24..e5b9670 100644 --- a/tests/test_pytest_mypy.py +++ b/tests/test_pytest_mypy.py @@ -122,29 +122,6 @@ def pyfunc(x): return x * y """, ) - min_mypy_version = Version("0.990") - if MYPY_VERSION < min_mypy_version: - # mypy doesn't emit annotation-unchecked warnings until 0.990: - fake_mypy_path = tmp_path / "mypy" - fake_mypy_path.mkdir() - (fake_mypy_path / "__init__.py").touch() - (fake_mypy_path / "api.py").write_text( - textwrap.dedent( - """ - def run(*args, **kwargs): - return ( - "test_mypy_annotation_unchecked.py:2:" - " note: By default the bodies of untyped functions" - " are not checked, consider using --check-untyped-defs" - " [annotation-unchecked]\\nSuccess: no issues found in" - " 1 source file\\n", - "", - 0, - ) - """ - ) - ) - monkeypatch.setenv("PYTHONPATH", str(tmp_path)) result = testdir.runpytest_subprocess(*xdist_args) result.assert_outcomes() result = testdir.runpytest_subprocess("--mypy", *xdist_args) @@ -153,9 +130,7 @@ def run(*args, **kwargs): mypy_checks = mypy_file_checks + mypy_status_check outcomes = {"passed": mypy_checks} result.assert_outcomes(**outcomes) - # mypy doesn't emit annotation-unchecked warnings until 0.990: - if MYPY_VERSION >= Version("0.990"): - result.stdout.fnmatch_lines(["*MypyWarning*"]) + result.stdout.fnmatch_lines(["*MypyWarning*"]) assert result.ret == 0 @@ -409,10 +384,6 @@ def pytest_configure(config): assert result.ret != 0 -@pytest.mark.xfail( - Version("0.900") > MYPY_VERSION, - reason="Mypy added pyproject.toml configuration in 0.900.", -) def test_pyproject_toml(testdir, xdist_args): """Ensure that the plugin allows configuration with pyproject.toml.""" testdir.makefile( @@ -590,11 +561,6 @@ def test_mypy_item_collect(request): assert result.ret == 0 -@pytest.mark.xfail( - MYPY_VERSION < Version("0.750"), - raises=AssertionError, - reason="https://github.com/python/mypy/issues/7800", -) def test_mypy_results_from_mypy_with_opts(): """MypyResults.from_mypy respects passed options.""" mypy_results = pytest_mypy.MypyResults.from_mypy([], opts=["--version"]) @@ -603,12 +569,6 @@ def test_mypy_results_from_mypy_with_opts(): assert str(MYPY_VERSION) in mypy_results.stdout -@pytest.mark.xfail( - Version("3.7") < PYTHON_VERSION < Version("3.9") - and Version("0.710") <= MYPY_VERSION < Version("0.720"), - raises=AssertionError, - reason="Mypy crashes for some reason.", -) def test_mypy_no_output(testdir, xdist_args): """No terminal summary is shown if there is no output from mypy.""" type_ignore = ( @@ -616,7 +576,6 @@ def test_mypy_no_output(testdir, xdist_args): if ( PYTEST_VERSION < Version("6.0") # Pytest didn't add type annotations until 6.0. - or MYPY_VERSION < Version("0.710") ) else "" ) diff --git a/tox.ini b/tox.ini index 090085e..f8ebf12 100644 --- a/tox.ini +++ b/tox.ini @@ -3,23 +3,23 @@ minversion = 4.4 isolated_build = true envlist = - py37-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.50, 0.x, 1.0, 1.x} - py38-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.71, 0.x, 1.0, 1.x} - py39-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.78, 0.x, 1.0, 1.x} - py310-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.78, 0.x, 1.0, 1.x} - py311-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.90, 0.x, 1.0, 1.x} - py312-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.90, 0.x, 1.0, 1.x} + py37-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{1.0, 1.x} + py38-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + py39-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + py310-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + py311-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + py312-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} publish static [gh-actions] python = - 3.7: py37-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.50, 0.x, 1.0, 1.x} - 3.8: py38-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.71, 0.x, 1.0, 1.x}, publish, static - 3.9: py39-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.78, 0.x, 1.0, 1.x} - 3.10: py310-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.78, 0.x, 1.0, 1.x} - 3.11: py311-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.90, 0.x, 1.0, 1.x} - 3.12: py312-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{0.90, 0.x, 1.0, 1.x} + 3.7: py37-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{1.0, 1.x} + 3.8: py38-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}, publish, static + 3.9: py39-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + 3.10: py310-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + 3.11: py311-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} + 3.12: py312-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x} [testenv] constrain_package_deps = true @@ -34,11 +34,6 @@ deps = pytest7.x: pytest ~= 7.0 pytest8.0: pytest ~= 8.0.0 pytest8.x: pytest ~= 8.0 - mypy0.50: mypy >= 0.500, < 0.510 - mypy0.71: mypy >= 0.710, < 0.720 - mypy0.78: mypy >= 0.780, < 0.790 - mypy0.90: mypy >= 0.900, < 0.910 - mypy0.x: mypy ~= 0.0 mypy1.0: mypy ~= 1.0.0 mypy1.x: mypy ~= 1.0