Skip to content

Move norecursedir check to the pytest_ignore_collect hook #11081

Closed

Description

@bluetech

Currently the two recursive collectors Session and Package perform the norecursedir check directly in the collector:

pytest/src/_pytest/main.py

Lines 566 to 568 in 85c5bd2

norecursepatterns = self.config.getini("norecursedirs")
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
return False

norecursepatterns = self.config.getini("norecursedirs")
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
return False

I think it would be strictly better to move this check to main's pytest_ignore_collect hookimpl:

  • Less duplication
  • Better decoupling -- only main knows about the option it defines
  • More control for plugins

Activity

  1. added
    type: proposalproposal for a new feature, often to gather opinions or design the API around the new feature
    on Jun 5, 2023
  2. self-assigned this
    on Jun 5, 2023
  3. added a commit that references this issue on Jun 5, 2023
    ae38b07
  4. added 2 commits that reference this issue on Apr 18, 2026
    657c01e
    e9b6001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

topic: collectionrelated to the collection phasetype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions