azure-sdk-for-python: Mypy doesn't work with azure-storage-blob
- Package Name: azure-storage-blob
- Package Version: 12.8.1
- Operating System: Ubuntu 20.04
- Python Version: 3.8.10
Describe the bug If I want to use mypy to statically type check my Python code it fails to find the type information of the azure.storage.blob, despite that there are type comments in the module.
To Reproduce Steps to reproduce the behavior:
pip install azure-storage-blob==12.8.1 mypy==0.910
echo "from azure.storage.blob import ContainerClient" > test.py
mypy test.py
test.py:1: error: Skipping analyzing "azure.storage.blob": found module but no type hints or library stubs test.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports Found 1 error in 1 file (checked 1 source file)
Expected behavior I expect mypy to find the type hints in the module.
Additional context
There seem to be type annotations in the code. I asked in the https://gitter.im/python/typing chat and was told that the issue is that there isn’t a py.typed
file in the package, which seems to be true, since I can’t find it in lib/python3.8/site-packages/azure/storage/blob
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (8 by maintainers)
Commits related to this issue
- lint: ignore types coming from azure blob storage they are internally incorrect, and will lead to mypy errors see https://github.com/Azure/azure-sdk-for-python/issues/20083 — committed to Cornerstone-OnDemand/modelkit by deleted user 3 years ago
- lint: ignore types coming from azure blob storage they are internally incorrect, and will lead to mypy errors see https://github.com/Azure/azure-sdk-for-python/issues/20083 — committed to Cornerstone-OnDemand/modelkit by deleted user 3 years ago
- lint: ignore types coming from azure blob storage they are internally incorrect, and will lead to mypy errors see https://github.com/Azure/azure-sdk-for-python/issues/20083 — committed to Cornerstone-OnDemand/modelkit by deleted user 3 years ago
Now 12.9.0 has been released with the still-broken typing, so users who pick up the latest package and run mypy over their code are exposed to this.
Many thanks for that PR and the issue to validate all packages; much appreciated.
Not sure if this question was for me… I don’t fully understand what you are asking.
We are not doing anything manually. Everything was working perfectly up to 12.8.1 —
mypy
was happily checking our codebases and was blissfully ignoringazure-storage-blob
.Then I guess you had
py.typed
added in 12.9.0 (even though the typings were bad) andmypy
started failing after upgradingazure-storage-blob
. Again, we didn’t do anything manually other than upgradingazure-storage-blob
to 12.9.0.None of the workarounds people suggested in the various issues relating to this works for us. The following, for example, makes no difference at all:
So our options are either sticking with 12.8.1 until all typing issues are fixed, or disabling
mypy
for the entire codebase 🙁That’s why I suggested earlier potentially getting a release out without
py.typed
, and only add it back when types are actually working.@polys that’s a good suggestion, I will discuss with our team if we can remove the typed file until mypy is fully validated.
I feel a bit bad about getting all of this started with my original issue after seeing how much trouble it caused 🙈
Hi @rnestler
Sorry for the delay. Thanks for the pr! It looks great!