Skip to content
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

feat: ship py.typed to allow type checking #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nijel
Copy link
Contributor

@nijel nijel commented Jan 6, 2025

The py.typed needs to be present in the module to make type checking work (see PEP 561). In order to make it possible, the module can no longer be a single file, but needs to be installed in a directory.

@honzajavorek
Copy link
Owner

This might take me some time as it's not something I'll benefit from (I'm a typing heretic, and kinda okay checking Python types just in VS Code with the pyright server), and I'm not a big fan of having code in the init file. Unless this has great benefits for users of the package, I'll probably procrastinate this until the code becomes a package (as in 'Python files inside directory') for other reasons.

@nijel
Copy link
Contributor Author

nijel commented Jan 6, 2025

Without that mypy won't use type hints in this module. I can structure the module more, I just wanted to minimize the changes for this pull request.

The py.typed needs to be present in the module to make type checking
work (see PEP 561). In order to make it possible, the module can no
longer be a single file, but needs to be installed in a directory.
@nijel
Copy link
Contributor Author

nijel commented Jan 9, 2025

I've moved the code from __init__.py now. As mentioned before, having py.typed is the only way for type checkers to be able to use type hints in a third-party code using this module.

@honzajavorek
Copy link
Owner

honzajavorek commented Jan 9, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants