Skip to content

Commit

Permalink
Fixed pytest_ignore_collect not to block default pytest code (#464)
Browse files Browse the repository at this point in the history
Fixed `pytest_ignore_collect` hook implementation to return `None` rather than `False` when the path ought not to be ignored.  This is necessary to enable the default pytest implementation of `pytest_ignore_collect()` to be used.  Otherwise, the default rules are never applied and e.g. `--ignore` does not work.
  • Loading branch information
mgorny authored Nov 3, 2024
1 parent 6d6b4de commit 1c53caa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ This library adheres to
- Fixed checks against annotations wrapped in ``NotRequired`` not being run unless the
``NotRequired`` is a forward reference
(`#454 <https://github.com/agronholm/typeguard/issues/454>`_)
- Fixed the ``pytest_ignore_collect`` hook in the pytest plugin blocking default pytest
collection ignoring behavior by returning ``None`` instead of ``False``
(PR by @mgorny)

**4.4.0** (2024-10-27)

Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
pytest_plugins = ["pytester"]


def pytest_ignore_collect(collection_path: Path, config: pytest.Config) -> bool:
def pytest_ignore_collect(
collection_path: Path, config: pytest.Config
) -> typing.Optional[bool]:
match = version_re.search(collection_path.name)
if match:
version = tuple(int(x) for x in match.groups())
if sys.version_info < version:
return True

return False
return None


@pytest.fixture
Expand Down

0 comments on commit 1c53caa

Please sign in to comment.