python-amazon-paapi
python-amazon-paapi copied to clipboard
Bug: Type hints not working as expected
Steps to reproduce
- Check out this example repository: https://github.com/YPCrumble/amazon-paapi-test
- Create a virtualenvironment and install mypy
- Run
mypy .
and you should get this following error:
example/example.py:1: error: Skipping analyzing "amazon_paapi.models.item_result": module is installed, but missing library stubs or py.typed marker
example/example.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
example/example.py:5: note: Revealed type is "Any"
Current behavior MyPy type hints are not being picked up from the package
Expected behavior
I would expect the revealed type of result
to be Item
, and I would expect MyPy to raise an error for the subsequent statement, print(result.item_info.content_info)
, because item_info.content_info
could be None
per my previous commit, so item_info.content_info.publication_date
can potentially raise an AttributeError
.
This is the relevant section of the MyPy docs as to why this might be happening: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker