tpm2-software / tpm2-pytss

Python bindings for TSS
https://tpm2-pytss.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
56 stars 42 forks source link

tox complains about missing library stubs or py.typed.marker #362

Open Dvergatal opened 2 years ago

Dvergatal commented 2 years ago

Like in subject during testing our code which uses pytss I'm getting this errors:

device/tpm.py:5: error: Skipping analyzing "tpm2_pytss.ESAPI": module is installed, but missing library stubs or py.typed marker
device/tpm.py:5: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
device/tpm.py:6: error: Skipping analyzing "tpm2_pytss.utils": module is installed, but missing library stubs or py.typed marker
device/tpm.py:7: error: Skipping analyzing "tpm2_pytss.types": module is installed, but missing library stubs or py.typed marker
device/tpm.py:8: error: Skipping analyzing "tpm2_pytss.constants": module is installed, but missing library stubs or py.typed marker
Found 4 errors in 1 file (checked 49 source files)
ERROR: InvocationError for command /work/.tox/mypy/bin/mypy . --strict (exited with code 1)

I suppose, that as the link suggests we are missing typing support in tpm2-pytss package.

williamcroberts commented 2 years ago

What is exactly is this? What's tox (looks like a testing framework)? How do I reproduce? Did you build the package or just grab the code, if you don't pip install it you won't generate the bindings.

Dvergatal commented 2 years ago

Our code uses imports from tpm2_pytss. The tpm2_pytss is installed using this command:

python3 -m pip install tpm2-ptss

with newest version 1.2.0. As you can see in my previous log, there is a hint link missing imports, where you can read about this error. tox uses mypy package for static analysis of our code and due to this test I'm getting these errors.

The command which is in tox.ini looks like that:

commands =
    mypy: mypy . --strict
williamcroberts commented 2 years ago

So, per the docs:

Mypy will not try inferring the types of any 3rd party libraries you have installed unless they either have declared themselves to be [PEP 561 compliant stub package](https://mypy.readthedocs.io/en/stable/installed_packages.html#installed-packages) (e.g. with a py.typed file) or have registered themselves on [typeshed](https://github.com/python/typeshed), the repository of types for the standard library and some 3rd party libraries.

So we need a py.typed file I think... I need information on how to reproduce.

Dvergatal commented 2 years ago

Ok I have prepared fully workable docker for you with little code, which only imports from tpm2-pytss. To run and get the errors please run this command:

docker-compose run test

mypy-tpm-test.zip