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

Add py.typed file #833

Merged
merged 1 commit into from
May 27, 2022
Merged

Add py.typed file #833

merged 1 commit into from
May 27, 2022

Conversation

ljodal
Copy link
Contributor

@ljodal ljodal commented May 19, 2022

This is needed for mypy to read the type signatures defined in the project, ref https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages

There's also a note about needing zip_safe=False, but I'm not to familiar with setuptools so I didn't want to add that unless it's strictly required.

@dlech
Copy link
Collaborator

dlech commented May 19, 2022

Thanks! Could you also add a changelog entry?

There's also a note about needing zip_safe=False, but I'm not to familiar with setuptools so I didn't want to add that unless it's strictly required.

To test this, you could run python setup.py sdist bdist_wheel (in an environment with setuptools and wheel packages installed) and inspect the resulting files.

@ljodal
Copy link
Contributor Author

ljodal commented May 20, 2022

Thanks for the quick feedback! Wasn't sure if this was big enough to warrant a changelog entry, but I'll get that fixed and check the zip_safe flag over the weekend :)

@ljodal
Copy link
Contributor Author

ljodal commented May 27, 2022

Hey, sorry about the late follow up here. I researched the zip_safe flag and it seems to only be relevant for .egg distraction, which from what I understood is deprecated anyway. Looking into the PRs when the warning was added to mypy it seems like it's not a common issue, so I'm inclined skip that bit. Does that seem reasonable?

@dlech
Copy link
Collaborator

dlech commented May 27, 2022

As long as the empty py.typed file ends up in the binary wheel, it's fine with me. 😄

@ljodal
Copy link
Contributor Author

ljodal commented May 27, 2022

It does, running python setup.py sdist bdist_wheel it gets included in both the .whl and .tar.gz files :) I'll add a changelog entry and leave it at that.

Note that the typing experience with bleak isn't perfect after this, as noted in #822. At least in strict mode mypy will still complain:

scanner.py:5: error: Module "bleak" does not explicitly export attribute "BleakClient"; implicit reexport disabled  [attr-defined]
scanner.py:5: error: Module "bleak" does not explicitly export attribute "BleakScanner"; implicit reexport disabled  [attr-defined]

This is needed for mypy to read the type signatures defined in the
project, ref https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages
@dlech dlech merged commit a7fb67f into hbldh:develop May 27, 2022
@dlech
Copy link
Collaborator

dlech commented May 27, 2022

Thanks!

@dlech
Copy link
Collaborator

dlech commented May 27, 2022

Note that the typing experience with bleak isn't perfect after this, as noted in #822. At least in strict mode mypy will still complain:

scanner.py:5: error: Module "bleak" does not explicitly export attribute "BleakClient"; implicit reexport disabled  [attr-defined]
scanner.py:5: error: Module "bleak" does not explicitly export attribute "BleakScanner"; implicit reexport disabled  [attr-defined]

Another related discussion on these two types in particular is #582. It is a rather large chore, but would be nice for consuming the API with static analysis tools like mypy and pyright.

@ljodal ljodal deleted the add-py-typed-marker branch May 27, 2022 22:35
@ljodal
Copy link
Contributor Author

ljodal commented May 27, 2022

Yeah, I saw that issue and completely agree :)

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