Skip to content

Commit

Permalink
Require mypy >= 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtucker committed Aug 11, 2024
1 parent d0daa50 commit 0da2d13
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 60 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ requires-python = ">=3.7"
dependencies = [
"attrs>=19.0",
"filelock>=3.0",
"mypy>=0.50",
"mypy>=1.0",
"pytest>=4.6",
]

Expand Down
43 changes: 1 addition & 42 deletions tests/test_pytest_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"])
Expand All @@ -603,20 +569,13 @@ 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 = (
"# type: ignore"
if (
PYTEST_VERSION
< Version("6.0") # Pytest didn't add type annotations until 6.0.
or MYPY_VERSION < Version("0.710")
)
else ""
)
Expand Down
29 changes: 12 additions & 17 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 0da2d13

Please sign in to comment.