Skip to content

Added "exclude_files" option for pyproject.toml config usage. #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

mattgebert
Copy link
Contributor

Added an option for a exclude_files option in pyproject.toml config that allows re regular expression path exclusions.

Unfortunately, most yaml tags use exclude to refer to files, which perhaps doesn't apply to toml, but we already use the exclude label to notate object exclusion. I have introduced exclude_files instead to achieve the same purpose, which is almost processed identically to exclude except being utilized instead when iterating over the run_hook filepath list.

I'm not familiar with the Sphinx build checking options that exclude currently uses. Do I/we need to implement a mapping for this in that location too?

Solution to Issue #497

…onfig option `exclude_files` that allows regex path exclusions

Solution to Issue numpy#497
@mattgebert mattgebert changed the title Added "exclude Added "exclude_files" option for pyproject.toml config usage. Jun 26, 2025
@larsoner
Copy link
Collaborator

I'm not familiar with the Sphinx build checking options that exclude currently uses. Do I/we need to implement a mapping for this in that location too?

I think ideally yes so that the hook and the Sphinx-based checking both function similarly. In principle they should use 99% of the same mechanics so hopefully it won't be too hard to add at the Sphinx end...

…fg test cases for the `exclude_files` option
…iles` for Sphinx plugin

Uses very similar regex processing to `numpydoc_validation_exclude` but instead applies to a module check before any numpydoc validation is performed.
…inx option to use `inspect`, and simplified path checking using `__file__`
…ate-if-`numpydoc_validation_checks`-is-not-empty): Mimicing same behaviour as `numpydoc_validation_exclude`
…oc_validation_exclude_files` for Sphinx and `exclude_files` for pyproject.toml
@mattgebert
Copy link
Contributor Author

mattgebert commented Jun 27, 2025

@larsoner Thanks mate. I've figure that out now. I think the implementation is succinct. I currently don't have any projects with a sphinx production (in the process of setting up my first) so it would be good if someone else can see if it behaves as intended. The new test cases work.

I've also updated the documentation to mimic exclude (pyproject.toml) / numpydoc_validation_exclude (sphinx) for exclude_files.

I have one concern about using the __file__ attribute of the module for checking the exclude Sphinx extension - do you think I ought to point the regex matching to the path relative to the package root, or the global path (the current implementation)?

@mattgebert mattgebert marked this pull request as ready for review June 27, 2025 16:56
excluder = app.config.numpydoc_validation_files_excluder
module = inspect.getmodule(obj)
try:
path = module.__file__ if module else None
Copy link
Contributor Author

@mattgebert mattgebert Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly problematic to get global path to module file, rather than relative path to a package root? Perhaps this is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants