Skip to content

Conversation

Rogdham
Copy link

@Rogdham Rogdham commented Jan 15, 2025

The py.typed file must be distributed (according to PEP 561) to indicate to type checkers that the package suport type hints.

This PR adds the file, but I don't know how you package your library, so make sure that the py.typed file is in the resulting wheel and source build as well.


As an illustration, given the following input file:

from umsgpack import packb
from typing import reveal_type

data = packb({"hello": "world!"})
reveal_type(data)

…here is the output of mypy (version 1.14.1) currently:

foo.py:1: error: Skipping analyzing "umsgpack": module is installed, but missing library stubs or py.typed marker  [import-untyped]
foo.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
foo.py:5: note: Revealed type is "Any"
Found 1 error in 1 file (checked 1 source file)

…whereas here is the output if the py.typed file would have been present:

foo.py:5: note: Revealed type is "builtins.bytes"
Success: no issues found in 1 source file

@Rogdham Rogdham force-pushed the add-py.typed-marker branch from bb6603b to c6f398b Compare January 15, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant