A tool for automatically adding default values to Python type stubs.
Stub files, as specified in PEP 484 provide a way for type checkers to see the interface to a module that is not itself typed. Historically, default values for arguments were usually omitted in stub files, because they are not needed for type checking. However, stub files are also useful for IDEs, which do want to show defaults. Therefore, the typeshed project has decided to allow defaults for stubs. This tool provides a way to auto-add defaults for stubs.
Warning: The tool will import and/or install various packages. Make sure you trust the package you are trying to add defaults for. Please run it inside a virtual environment.
- Install the package by running
pip install stubdefaulter
- Invoke it as
python -m stubdefaulter
- Example invocations:
python -m stubdefaulter --stdlib-path path/to/typeshed/stdlib
- Add defaults to the stdlib stubs in typeshed
python -m stubdefaulter --packages path/to/typeshed/stubs/requests path/to/typeshed/stubs/babel
- Add defaults to the
requests
andbabel
packages in typeshed - Assumes you already have these installed locally
- Add defaults to the
python -m stubdefaulter --typeshed-packages path/to/typeshed/stubs/requests path/to/typeshed/stubs/babel
- Like the above, but also automatically installs the version of the package that typeshed supports
- Does not add values to variables and class attributes
Initial PyPI release.