Skip to content

Include py.typed in a package #936

@bonprosoft

Description

@bonprosoft

Feature request

Feature description

I use mypy, one of the most famous static type checkers in Python, to check my Python code depending on rclpy.
However, mypy won't use the type annotation of rclpy, since mypy only uses the type annotation of packages that are marked as PEP561-compatible (i.e. Packages that have py.typed inside).

Therefore, I can't check the code like:

$ cat foo.py
import rclpy

reveal_type(rclpy)
reveal_type(rclpy.init)

rclpy.foo  # should be error
rclpy.init(foo="bar")  # should be error

$ mypy foo.py 
foo.py:1: error: Cannot find implementation or library stub for module named 'rclpy'
foo.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
foo.py:3: note: Revealed type is 'Any'
foo.py:4: note: Revealed type is 'Any'
Found 1 error in 1 file (checked 1 source file)

Would it be possible to include py.typed in rclpy package? (I am happy to work on this task!)

Implementation considerations

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions