add py.typed file per PEP561 #846
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The (present-but-empty)
py.typedfile indicates to mypy (and presumably other type checkers) that this module supports type annotations.The problem: I have a repo which imports this SDK, but running
mypy main.pyon it gives a bunch of errors like this:These errors occur despite all the type annotations in the SDK.
The solution: in my virtual environment, I ran
touch venv/lib/python3.12/site-packages/viam/py.typed, and all those errors went away. This works because of PEP561, which says "Package maintainers who wish to support type checking of their code MUST add a marker file namedpy.typedto their package"This PR hopefully does the same thing to the official version. However, I'm unsure how to test this out, and would welcome help on that front!
Disclaimer: I'm still pinned to SDK version 0.29.3 from October. It's possible this has somehow been fixed since then, but if so, I didn't see it in the SDK repo.