tracelogging icon indicating copy to clipboard operation
tracelogging copied to clipboard

Python `traceloggingdynamic` package is missing `py.typed` marker file

Open bkeryan opened this issue 1 year ago • 0 comments

traceloggingdynamic.py has type hints, but type-checking client code with mypy results in the following errors:

my_module.py:4: error: Skipping analyzing "traceloggingdynamic": module is installed, but missing library stubs or py.typed marker  [import]
my_module.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 54 source files)

https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker says

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 (e.g. with a py.typed file) or have registered themselves on typeshed, the repository of types for the standard library and some 3rd party libraries.

https://peps.python.org/pep-0561/#packaging-type-information says

Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing. This marker applies recursively: if a top-level package includes it, all its sub-packages MUST support type checking as well.

I think the solution is to rename traceloggingdynamic.py to traceloggingdynamic/__init__.py and create an empty file traceloggingdynamic/py.typed.

Workaround: for mypy, specify --ignore-missing-imports

bkeryan avatar Aug 11 '23 16:08 bkeryan