-
Notifications
You must be signed in to change notification settings - Fork 3
Add --ignore
CLI option and ignore_files
config field
#60
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
lagru
wants to merge
10
commits into
main
Choose a base branch
from
glob-ignore-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c43551c
Add --ignore CLI option and ignore_files config option
lagru 04d5654
Add configuration reference
lagru f2044a6
Fix logic in `_load_configuration`
lagru 646ab1c
Fix outstanding warnings and errors
lagru b7ad864
Vendor glob.translate from Python 3.13.4
lagru 30f3b44
Merge branch 'main' into glob-ignore-files
lagru 264a707
Fix typo
lagru 1fa5165
Type vendored glob function
lagru fb1546d
Vendor fnmatch._translate too
lagru 918b339
Skip glob_patterns_to_regex doctests
lagru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
Files: * | ||
Copyright: 2025, Scientific Python Developers | ||
2024, Lars Grüter | ||
License: BSD 3-Clause | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
Files: src/docstub/_vendored/stdlib.py | ||
Copyright: 2001-2025, Python Software Foundation | ||
License: PSF-2.0 | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
License: BSD-3-Clause | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the vector package developers nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
------------------------------------------------------------------------------- | ||
|
||
License: PSF-2.0 | ||
|
||
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 | ||
-------------------------------------------- | ||
|
||
1. This LICENSE AGREEMENT is between the Python Software Foundation | ||
("PSF"), and the Individual or Organization ("Licensee") accessing and | ||
otherwise using this software ("Python") in source or binary form and | ||
its associated documentation. | ||
|
||
2. Subject to the terms and conditions of this License Agreement, PSF hereby | ||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, | ||
analyze, test, perform and/or display publicly, prepare derivative works, | ||
distribute, and otherwise use Python alone or in any derivative version, | ||
provided, however, that PSF's License Agreement and PSF's notice of copyright, | ||
i.e., "Copyright (c) 2001 Python Software Foundation; All Rights Reserved" | ||
are retained in Python alone or in any derivative version prepared by Licensee. | ||
|
||
3. In the event Licensee prepares a derivative work that is based on | ||
or incorporates Python or any part thereof, and wants to make | ||
the derivative work available to others as provided herein, then | ||
Licensee hereby agrees to include in any such work a brief summary of | ||
the changes made to Python. | ||
|
||
4. PSF is making Python available to Licensee on an "AS IS" | ||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR | ||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND | ||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS | ||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT | ||
INFRINGE ANY THIRD PARTY RIGHTS. | ||
|
||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON | ||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS | ||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, | ||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. | ||
|
||
6. This License Agreement will automatically terminate upon a material | ||
breach of its terms and conditions. | ||
|
||
7. Nothing in this License Agreement shall be deemed to create any | ||
relationship of agency, partnership, or joint venture between PSF and | ||
Licensee. This License Agreement does not grant permission to use PSF | ||
trademarks or trade name in a trademark sense to endorse or promote | ||
products or services of Licensee, or any third party. | ||
|
||
8. By copying, installing or otherwise using Python, Licensee | ||
agrees to be bound by the terms and conditions of this License | ||
Agreement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Configuration reference | ||
|
||
Docstub will automatically look for configuration in files named | ||
|
||
- `pyproject.toml`, and | ||
- `docstub.toml` | ||
|
||
in the current working directory. | ||
If config files are explicitly passed to the command line interface via the `--config` option, docstub won't look implicitly look for files in the current directory. | ||
Multiple configuration files can be used, whose content will be merged. | ||
|
||
Out of the box, docstub makes use of an internal configuration file [`numpy_config.toml`](../src/docstub/numpy_config.toml) which provides defaults to use NumPy types. | ||
|
||
|
||
## Configuration fields in `[tool.docstub]` | ||
|
||
All configuration must be declared inside a `[tool.docstub]` table. | ||
|
||
|
||
### `ignore_files` | ||
|
||
- [TOML type](https://toml.io/en/latest): array of string(s) | ||
|
||
Ignore files and directories matching these [glob-style patterns](https://docs.python.org/3/library/glob.html#glob.translate). | ||
Patterns that don't start with "/" are interpreted as relative to the | ||
directory that contains the Python package for which stubs are generated. | ||
|
||
Example: | ||
|
||
```toml | ||
[tool.docstub] | ||
ignore_files = [ | ||
"**/tests", | ||
] | ||
``` | ||
|
||
- Will ignore any directory anywhere that is named `tests`. | ||
|
||
|
||
### `types` | ||
|
||
- [TOML type](https://toml.io/en/latest): table, mapping string to string | ||
|
||
Types and their external modules to use in docstrings. | ||
Docstub can't yet automatically discover where to import types from other packages from. | ||
Instead, you can provide this information explicitly. | ||
Any type on the left side will be associated with the given "module" on the right side. | ||
|
||
Example: | ||
|
||
```toml | ||
[tool.docstub.types] | ||
Path = "pathlib" | ||
NDArray = "numpy.typing" | ||
``` | ||
|
||
- Will allow using `Path` in docstrings and will use `from pathlib import Path` to import the type. | ||
- Will allow using `NDarray` in docstrings and will use `from numpy.typing import NDArray` to import the type. | ||
|
||
|
||
### `type_prefixes` | ||
|
||
- [TOML type](https://toml.io/en/latest): table, mapping string to string | ||
|
||
Prefixes for external modules to match types in docstrings. | ||
Docstub can't yet automatically discover where to import types from other packages from. | ||
Instead, you can provide this information explicitly. | ||
Any type in a docstring whose prefix matches the name given on the left side, will be associated with the given "module" on the right side. | ||
|
||
Example: | ||
|
||
```toml | ||
[tool.docstub.type_prefixes] | ||
np = "numpy" | ||
plt = "matplotlib.pyplot | ||
``` | ||
|
||
- Will match `np.uint8` and `np.typing.NDarray` and use `import numpy as np`. | ||
- Will match `plt.Figure` use `import matplotlib.pyplot as plt`. | ||
|
||
|
||
### `type_nicknames` | ||
|
||
- [TOML type](https://toml.io/en/latest): table, mapping string to string | ||
|
||
Nicknames for types that can be used in docstrings to describe valid Python types or annotations. | ||
|
||
Example: | ||
|
||
```toml | ||
[tool.docstub.type_nicknames] | ||
func = "Callable" | ||
``` | ||
|
||
- Will map `func` to the `Callable` type from the `typing` module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefanv could I ask you to take a look if I handled the license situation correctly here? I'd like to vendor Python's
glob.translate
which is only available from 3.13 onward.I'm also not sure if need to adapt the SPDX license identifier in the
pyproject.toml
since the vendored part now uses a different one. 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been starting to use the SPDX identifiers. There is now a new PEP that allows you to use a specifier+file in pyproject.toml.
Your file seems to be formatted roughly correctly according to https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#stanzas, except for the dashes.