Skip to content

Commit

Permalink
Add ignores on incompatible conditional defs
Browse files Browse the repository at this point in the history
  • Loading branch information
zero323 committed Dec 21, 2021
1 parent 238d7c3 commit 652919d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pytest_mypy_plugins/collect.py
Expand Up @@ -12,6 +12,7 @@
Mapping,
Optional,
Set,
no_type_check,
)

import pkg_resources
Expand Down Expand Up @@ -151,18 +152,21 @@ def _eval_skip(self, skip_if: str) -> bool:
return eval(skip_if, {"sys": sys, "os": os, "pytest": pytest, "platform": platform})


if pkg_resources.parse_version(pytest.__version__) < pkg_resources.parse_version("7.0.0rc1"):
if pkg_resources.parse_version(pytest.__version__) >= pkg_resources.parse_version("7.0.0rc1"):

def pytest_collect_file(path: LocalPath, parent: Node) -> Optional[YamlTestFile]:
if path.ext in {".yaml", ".yml"} and path.basename.startswith(("test-", "test_")):
return YamlTestFile.from_parent(parent, fspath=path)
@no_type_check
def pytest_collect_file(file_path: pathlib.Path, parent: Node) -> Optional[YamlTestFile]:
if file_path.suffix in {".yaml", ".yml"} and file_path.name.startswith(("test-", "test_")):
return YamlTestFile.from_parent(parent, path=file_path)
return None


else:

def pytest_collect_file(file_path: pathlib.Path, parent: Node) -> Optional[YamlTestFile]:
if file_path.suffix in {".yaml", ".yml"} and file_path.name.startswith(("test-", "test_")):
return YamlTestFile.from_parent(parent, path=file_path)
@no_type_check
def pytest_collect_file(path: LocalPath, parent: Node) -> Optional[YamlTestFile]:
if path.ext in {".yaml", ".yml"} and path.basename.startswith(("test-", "test_")):
return YamlTestFile.from_parent(parent, fspath=path)
return None


Expand Down

0 comments on commit 652919d

Please sign in to comment.