[FR] Include type information by default (*.pyi, py.typed) - PEP 561 · Issue #3136 · pypa/setuptools (original) (raw)

What's the problem this feature will solve?

PEP 561 specifies how type information should be included in a distributions. Namely package authors may choose to add py.typed files to fully typed packages and / or include .pyi stub files. By default, those files won't be included in the sdist / wheel distribution packages.

To add them, a package author needs to set include_package_data = True and include them via the MANIFEST.in or with options.package_data (eg. with * = py.typed, *.pyi). Although there are some great guides out there explaining it, I believe we could make this much simpler.

https://blog.whtsky.me/tech/2021/dont-forget-py.typed-for-your-typed-python-package/
https://jugmac00.github.io/blog/bite-my-shiny-type-annotated-library/

Describe the solution you'd like

Add a new option include_typing_files or include_typing_information as a shorthand for options.package_data-> * = py.typed, *.pyi.

How should it be used?
Authors wanting to include typing files (py.typed / stub files) should set both include_package_data = True and include_typing_files = True.

How would it work with other options to include package data files?
Conceptually this option would add the * = py.typed, *.pyi pattern to options.package_data. This also means any file matched by exclude_package_data should still be excluded.

Alternative Solutions

Don't require include_package_data = True. Similar to license files, one could argue if an author sets include_typing_files = True, they already expressed what they want to do. No need to require an additional option.

Include py.typed and *.pyi files by default.

Additional context

If others agree that this is something worth adding, I could work on a PR for it.

Code of Conduct