I'm adding type annotations to a package I maintain. According to PEP484 stub files for type annotation (.pyi) can either be distributed alongside the actual code in the same directory or in a third-party package. Having the .pyi files in the same directory, however, seems inelegant and I would much prefer to have them separated; similar to how this is done for headers and implementations in C/C++.
In a nutshell, my current package structure is something like this:
my_project
| setup.py
| pyproject.toml
| ...
|
|___my_package
| | __init__.py
| |___module_1
| | | __init.py
| | | fancy_module.py
| | | fancy_module.pyi
| | | ...
| |
| |___module_2
| | | __init__.py
| | | more_files.py
| | | more_files.pyi
| | | ...
and I would like it to be something like this (with type annotations supported by mypy and vscode at least):
my_project
| setup.py
| pyproject.toml
| ...
|
|___my_package
| | __init__.py
| |
| |___module_1
| | | __init.py
| | | fancy_module.py
| | | ...
| |
| |___module_2
| | | __init__.py
| | | more_files.py
| | | ...
|
|___stubs
| |___module1
| | | fancy_module.pyi
| | | ...
| |
| |___module2
| | | more_files.pyi
| | | ...
Is this possible or do I need to look into distributing a separate "third-party" package?
from Is it possible to have type hints in a separate folder within the same project?
No comments:
Post a Comment