You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, numpydoc requires configuration to be present in either pyproject.toml or setup.cfg files within each Python package. This creates challenges in monorepo setups where multiple Python packages need to share common docstring validation rules and configurations.
Use Case: Monorepo Setup
In a monorepo with multiple Python packages, maintaining consistent docstring standards across all packages becomes challenging. Consider this structure:
# libs/lib1/pyproject.toml
[tool.numpydoc_validation]
extends = "../../resources/numpydoc.toml"
[tool.poe.tasks.validate-docs]
help = "Run docstring validation via numpydoc"script = "numpydoc lint --config=../../resources/numpydoc.toml src/**/*.py"
This setup allows:
Centralized configuration in resources/ directory (similar to how ruff handles its configuration)
Easy reference to shared config files from package-specific tasks
Consistent validation across all packages using poethepoet tasks
Proposed Solution
Add support for a standalone numpydoc.toml configuration file that can be referenced from multiple packages, with the ability to override settings locally when needed.
Configuration Format
# numpydoc.toml
[tool.numpydoc_validation]
checks = [
"all", # report on all checks, except the below"EX01",
"SA01",
"ES01",
]
# remember to use single quotes for regex in TOMLexclude = [ # don't report on objects that match any of these regex'\.undocumented_method$',
'\.__repr__$',
]
override_SS05 = [ # override SS05 to allow docstrings starting with these words'^Process ',
'^Assess ',
'^Access ',
]
# Optional: Allow packages to extend this configallow_local_override = true
Local Package Override (in pyproject.toml)
[tool.numpydoc_validation]
# Reference the shared configextends = "../resources/numpydoc.toml"# Override specific settingsexclude = [
'\._internal_', # Additional package-specific exclusions
]
Benefits
Centralized Configuration:
Single source of truth for docstring standards
Easier maintenance and updates
Consistent validation across packages
Flexibility:
Support for local overrides when needed
Backward compatible with existing setups
Similar to other tools like ruff, black, etc.
Improved Monorepo Support:
Better handling of multi-package repositories
Reduced configuration duplication
Easier to maintain consistency
Technical Implementation
Add support for standalone numpydoc.toml file
Implement configuration inheritance:
# Configuration precedence (highest to lowest):# 1. Command line arguments# 2. Local pyproject.toml/setup.cfg# 3. Referenced numpydoc.toml# 4. Default settings
This can be a nice feature since I personally do not use the pyproject.toml override part and I abstract out all the resource files that are needed for formatting/linting/... in a separate directory; this is very true for a mono-repo project with tons of pyproject.toml; In this way, we do not copy/paste the same code over and over
Problem Statement
Currently, numpydoc requires configuration to be present in either
pyproject.toml
orsetup.cfg
files within each Python package. This creates challenges in monorepo setups where multiple Python packages need to share common docstring validation rules and configurations.Use Case: Monorepo Setup
In a monorepo with multiple Python packages, maintaining consistent docstring standards across all packages becomes challenging. Consider this structure:
Example Package Configuration
This setup allows:
resources/
directory (similar to how ruff handles its configuration)Proposed Solution
Add support for a standalone
numpydoc.toml
configuration file that can be referenced from multiple packages, with the ability to override settings locally when needed.Configuration Format
Local Package Override (in pyproject.toml)
Benefits
Centralized Configuration:
Flexibility:
Improved Monorepo Support:
Technical Implementation
numpydoc.toml
fileSimilar Implementations
ruff.toml
with inheritance supportpyproject.toml
Backward Compatibility
The feature maintains backward compatibility:
pyproject.toml
/setup.cfg
continue to workconfig_file
parameter is optionalWould love to hear thoughts on this approach and any suggestions for improvement.
The text was updated successfully, but these errors were encountered: