Yubico / python-fido2

Provides library functionality for FIDO 2.0, including communication with a device over USB.
BSD 2-Clause "Simplified" License
432 stars 109 forks source link

adding py.typed to enable mypy, if used as library #142

Closed daringer closed 2 years ago

daringer commented 2 years ago

This package is well typed, in order to use it as a library it should be marked as typed as explained here: https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages

This PR adds a py.typed file and includes it inside pyproject.toml so anyone including this package as a library/dependency can use mypy for type-checking.

dainnilsson commented 2 years ago

Thanks! Though looking at the provided link, shouldn't the py.typed file be located in the fido2 directory rather than the root?

daringer commented 2 years ago

yes, you are right, the final py.typed file did not end up where it should. Made the necessary changes and tested like that (with the repository being the current work directory):

# set up virtual env
$ python -m venv /tmp/my-test-venv

# install python-fido2 into virtual env
$ /tmp/my-test-venv/bin/python -m pip install .

# check py.typed is at the right spot
$ stat /tmp/my-test-venv/lib/python-3.*/site-packages/fido2/py.typed
dainnilsson commented 2 years ago

You shouldn't need the change to pyproject.toml, the file should get included anyway.

daringer commented 2 years ago

Indeed, updated!

dainnilsson commented 2 years ago

Thanks! Merged!