From 0c68c07c7639d3910e974524b1fb576a817ae099 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Sat, 11 Jun 2022 12:51:49 -0700 Subject: [PATCH 1/4] Upgrade black This picks up the fix for https://github.com/psf/black/issues/2964 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 71fa95b..f6d8c97 100644 --- a/tox.ini +++ b/tox.ini @@ -90,7 +90,7 @@ commands = [testenv:static] deps = bandit ~= 1.7.0 - black ~= 21.6b + black ~= 22.3.0 flake8 ~= 3.9.0 flake8-commas ~= 2.0.0 mypy >= 0.900, < 0.910 From e9bc67b9b6aa603aee08dd64de0d2bdd395dd940 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Sat, 11 Jun 2022 13:13:58 -0700 Subject: [PATCH 2/4] Drop Python 3.5 support --- .github/workflows/validation.yml | 2 +- changelog.md | 3 +++ setup.py | 4 +--- src/pytest_mypy.py | 12 ++++-------- tox.ini | 2 -- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 66eb1a7..4e91771 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/changelog.md b/changelog.md index c5ff2b6..7e1a4bf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## [0.10.0](https://github.com/dbader/pytest-mypy/milestone/18) +* Drop support for python<3.6. + ## [0.9.1](https://github.com/dbader/pytest-mypy/milestone/17) * Add support for pytest 7. diff --git a/setup.py b/setup.py index 6680643..ae12003 100644 --- a/setup.py +++ b/setup.py @@ -29,12 +29,11 @@ def read(fname): py_modules=[ os.path.splitext(os.path.basename(path))[0] for path in glob.glob("src/*.py") ], - python_requires=">=3.5", + python_requires=">=3.6", setup_requires=["setuptools-scm>=3.5"], install_requires=[ "attrs>=19.0", "filelock>=3.0", - 'pytest>=4.6,<7.0; python_version>="3.5" and python_version<"3.6"', 'pytest>=4.6; python_version>="3.6" and python_version<"3.10"', 'pytest>=6.2; python_version>="3.10"', 'mypy>=0.500; python_version<"3.8"', @@ -48,7 +47,6 @@ def read(fname): "Topic :: Software Development :: Testing", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/src/pytest_mypy.py b/src/pytest_mypy.py index 862b097..d067925 100644 --- a/src/pytest_mypy.py +++ b/src/pytest_mypy.py @@ -97,14 +97,14 @@ def pytest_configure_node(self, node): # xdist hook config.addinivalue_line( "markers", - "{marker}: mark tests to be checked by mypy.".format(marker=MypyItem.MARKER), + f"{MypyItem.MARKER}: mark tests to be checked by mypy.", ) if config.getoption("--mypy-ignore-missing-imports"): mypy_argv.append("--ignore-missing-imports") mypy_config_file = config.getoption("--mypy-config-file") if mypy_config_file: - mypy_argv.append("--config-file={}".format(mypy_config_file)) + mypy_argv.append(f"--config-file={mypy_config_file}") def pytest_collect_file(file_path, parent): @@ -221,11 +221,7 @@ def runtest(self): """Raise a MypyError if mypy exited with a non-zero status.""" results = MypyResults.from_session(self.session) if results.status: - raise MypyError( - "mypy exited with status {status}.".format( - status=results.status, - ), - ) + raise MypyError(f"mypy exited with status {results.status}.") @attr.s(frozen=True, kw_only=True) @@ -256,7 +252,7 @@ def from_mypy( cls, items: List[MypyFileItem], *, - opts: Optional[List[str]] = None # noqa: C816 + opts: Optional[List[str]] = None, ) -> "MypyResults": """Generate results from mypy.""" diff --git a/tox.ini b/tox.ini index f6d8c97..5416bda 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,6 @@ minversion = 3.20 isolated_build = true envlist = - py35-pytest{4.6, 5.0, 5.x, 6.0, 6.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x, 0.80, 0.8x, 0.90, 0.9x} py36-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x, 0.80, 0.8x, 0.90, 0.9x} py37-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x, 0.80, 0.8x, 0.90, 0.9x} py38-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.71, 0.7x, 0.80, 0.8x, 0.90, 0.9x} @@ -14,7 +13,6 @@ envlist = [gh-actions] python = - 3.5: py35-pytest{4.6, 5.0, 5.x, 6.0, 6.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x, 0.80, 0.8x, 0.90, 0.9x} 3.6: py36-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x, 0.80, 0.8x, 0.90, 0.9x} 3.7: py37-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x, 0.80, 0.8x, 0.90, 0.9x} 3.8: py38-pytest{4.6, 5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{0.71, 0.7x, 0.80, 0.8x, 0.90, 0.9x}, publish, static From 29823367a96d145966106f74aad134a43b560c20 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Sat, 11 Jun 2022 13:20:32 -0700 Subject: [PATCH 3/4] Upgrade flake8 flake8-commas is no longer maintained. --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 5416bda..211ad8f 100644 --- a/tox.ini +++ b/tox.ini @@ -89,8 +89,7 @@ commands = deps = bandit ~= 1.7.0 black ~= 22.3.0 - flake8 ~= 3.9.0 - flake8-commas ~= 2.0.0 + flake8 ~= 4.0.0 mypy >= 0.900, < 0.910 commands = black --check src setup.py tests From 3e6c6e552130204a5cc12db848b7f2b5a256edc4 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Sun, 25 Sep 2022 08:16:38 -0700 Subject: [PATCH 4/4] Xfail python/mypy#13701 --- tests/test_pytest_mypy.py | 18 ++++++++++++++---- tox.ini | 8 ++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/test_pytest_mypy.py b/tests/test_pytest_mypy.py index 10b2a0d..60c07f5 100644 --- a/tests/test_pytest_mypy.py +++ b/tests/test_pytest_mypy.py @@ -1,11 +1,14 @@ import signal import textwrap +import mypy.version +from packaging.version import Version import pexpect import pytest -PYTEST_VERSION = tuple(int(v) for v in pytest.__version__.split(".")[:2]) +MYPY_VERSION = Version(mypy.version.__version__) +PYTEST_VERSION = Version(pytest.__version__) @pytest.fixture( @@ -275,13 +278,18 @@ def pytest_configure(config): assert result.ret == 0 +@pytest.mark.xfail( + Version("0.971") <= MYPY_VERSION, + raises=AssertionError, + reason="https://github.com/python/mypy/issues/13701", +) @pytest.mark.parametrize( "module_name", [ pytest.param( "__init__", marks=pytest.mark.xfail( - (3, 10) <= PYTEST_VERSION < (6, 2), + Version("3.10") <= PYTEST_VERSION < Version("6.2"), raises=AssertionError, reason="https://github.com/pytest-dev/pytest/issues/8016", ), @@ -398,7 +406,7 @@ def pyfunc(x: int) -> str: ) num_tests = 2 - if module_name == "__init__" and (3, 10) <= PYTEST_VERSION < (6, 2): + if module_name == "__init__" and Version("3.10") <= PYTEST_VERSION < Version("6.2"): # https://github.com/pytest-dev/pytest/issues/8016 # Pytest had a bug where it assumed only a Package would have a basename of # __init__.py. In this test, Pytest mistakes MypyFile for a Package and @@ -443,7 +451,9 @@ def _expect_success(): try: child.expect(str(num_tests) + " passed") except pexpect.exceptions.TIMEOUT: - if module_name == "__init__" and (6, 0) <= PYTEST_VERSION < (6, 2): + if module_name == "__init__" and ( + Version("6.0") <= PYTEST_VERSION < Version("6.2") + ): # MypyItems hit the __init__.py bug too when --looponfail # re-collects them after the failing file is modified. # Unlike MypyFile, MypyItem is not a Collector, so this used diff --git a/tox.ini b/tox.ini index 211ad8f..c9ea697 100644 --- a/tox.ini +++ b/tox.ini @@ -64,8 +64,16 @@ deps = mypy0.81: mypy >= 0.810, < 0.820 mypy0.8x: mypy >= 0.800, < 0.900 mypy0.90: mypy >= 0.900, < 0.910 + mypy0.91: mypy >= 0.910, < 0.920 + mypy0.92: mypy >= 0.920, < 0.930 + mypy0.93: mypy >= 0.930, < 0.940 + mypy0.94: mypy >= 0.940, < 0.950 + mypy0.95: mypy >= 0.950, < 0.960 + mypy0.96: mypy >= 0.960, < 0.970 + mypy0.97: mypy >= 0.970, < 0.980 mypy0.9x: mypy >= 0.900, <= 0.999 + packaging ~= 21.3 pexpect ~= 4.8.0 pytest-cov ~= 2.10 pytest-randomly ~= 3.4