A first prototype of the tool with the following features:
- Given a source directory
examples/example_pkg, create a stub files for every contained Python file inexamples/example-stubs/ - No need to import the source package!
- PYI files that already exist in the source package take precedence and are copied directly
- Type description in NumPy style docstrings are parsed and transformed into
Python ready type annotations
- supports
tuple of floatlike syntax - supports array syntax like:
(N,) uint8 array-likeorarray of dtype float and shape (10, ..., 3)(shape is discarded for now) - supports literals like
{"reflect", "mirror", "constant"} - supports
<some type>, optional, extra information - see included
examples/for more...
- supports
Anyis used wherever types are missing, except for the first parameter of methods and classmethods- Specify how used types can be imported via a map in
docstub.toml::[tool.docstub.docnames]. Imports usingfromandasare supported. This map can also serve to provide synonyms. - Created stub files are automatically formatted with isort and black, if these optional dependencies are available.