From e212be4c9e851166d4273451f3c9474814bd7e3c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 26 Oct 2022 10:06:30 +0200 Subject: [PATCH 1/2] Fix compatibility with pytest 7.2 (#106) With pytest 7.2, the remaining parts of the "py.path" library got vendored, to get rid of the dependency: https://github.com/pytest-dev/pytest/pull/10396 However, this breaks due to pytest_mypy_plugins importing private API: File ".../pytest_mypy_plugins/collect.py", line 13, in from py._path.local import LocalPath ModuleNotFoundError: No module named 'py._path'; 'py' is not a package Use py.path.local instead (the public name of the same type), which is part of the shim included in pytest. --- CHANGELOG.md | 6 ++++++ pytest_mypy_plugins/collect.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b01a5..be0fd68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Version history +## Version 1.10.1 + +### Bugfixes + +- Fixes compatibility with pytest 7.2, broken due to a private import from + `py._path`. ## Version 1.10.0 diff --git a/pytest_mypy_plugins/collect.py b/pytest_mypy_plugins/collect.py index a8ad8a0..637049d 100644 --- a/pytest_mypy_plugins/collect.py +++ b/pytest_mypy_plugins/collect.py @@ -6,11 +6,11 @@ from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Mapping, Optional, Set import pkg_resources +import py.path import pytest import yaml from _pytest.config.argparsing import Parser from _pytest.nodes import Node -from py._path.local import LocalPath from pytest_mypy_plugins import utils @@ -151,7 +151,7 @@ def pytest_collect_file(file_path: pathlib.Path, parent: Node) -> Optional[YamlT else: - def pytest_collect_file(path: LocalPath, parent: Node) -> Optional[YamlTestFile]: # type: ignore[misc] + def pytest_collect_file(path: py.path.local, parent: Node) -> Optional[YamlTestFile]: # type: ignore[misc] if path.ext in {".yaml", ".yml"} and path.basename.startswith(("test-", "test_")): return YamlTestFile.from_parent(parent, fspath=path) return None From 2a4fcd46b5ae448672c3f44cb83a4e735f0f0a5a Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 26 Oct 2022 12:44:10 +0300 Subject: [PATCH 2/2] Version 1.10.1 release (#107) * Version 1.10.1 release * Add 7.2 to the test * Fix types --- .github/workflows/test.yml | 3 ++- CHANGELOG.md | 3 +++ pytest_mypy_plugins/collect.py | 14 ++++++++++++-- setup.py | 4 +--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1bbdfcf..1368b72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,8 @@ jobs: strategy: matrix: python-version: ["3.7", "3.8", "3.9", "3.10"] - pytest-version: ["~=6.2", "~=7.1"] + # TODO: remove `7.1` in the next release + pytest-version: ["~=6.2", "~=7.1", "~=7.2"] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index be0fd68..87cdcd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,15 @@ # Version history + ## Version 1.10.1 ### Bugfixes +- Removes unused depenencies for `python < 3.7` - Fixes compatibility with pytest 7.2, broken due to a private import from `py._path`. + ## Version 1.10.0 ### Features diff --git a/pytest_mypy_plugins/collect.py b/pytest_mypy_plugins/collect.py index 637049d..ea1c653 100644 --- a/pytest_mypy_plugins/collect.py +++ b/pytest_mypy_plugins/collect.py @@ -3,7 +3,17 @@ import platform import sys import tempfile -from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Mapping, Optional, Set +from typing import ( + TYPE_CHECKING, + Any, + Dict, + Hashable, + Iterator, + List, + Mapping, + Optional, + Set, +) import pkg_resources import py.path @@ -63,7 +73,7 @@ def parse_parametrized(params: List[Mapping[str, Any]]) -> List[Mapping[str, Any class SafeLineLoader(yaml.SafeLoader): - def construct_mapping(self, node: yaml.Node, deep: bool = False) -> None: + def construct_mapping(self, node: yaml.MappingNode, deep: bool = False) -> Dict[Hashable, Any]: mapping = super().construct_mapping(node, deep=deep) # Add 1 so line numbering starts at 1 starting_line = node.start_mark.line + 1 diff --git a/setup.py b/setup.py index 706d140..0d59571 100644 --- a/setup.py +++ b/setup.py @@ -10,12 +10,11 @@ "pyyaml", "chevron", "regex", - "dataclasses ; python_version<'3.7'", ] setup( name="pytest-mypy-plugins", - version="1.10.0", + version="1.10.1", description="pytest plugin for writing tests for mypy plugins", long_description=readme, long_description_content_type="text/markdown", @@ -36,7 +35,6 @@ classifiers=[ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9",