Skip to content

Commit

Permalink
add py.typed file per PEP561 (#846)
Browse files Browse the repository at this point in the history
The (present-but-empty) `py.typed` file indicates to mypy (and presumably other type checkers) that this module supports type annotations. 

The problem: I have [a repo](https://github.com/viam-modules/re-id-object-tracking) which imports this SDK, but running `mypy main.py` on it gives a bunch of errors like this:
```
src/config/attribute.py:3: error: Skipping analyzing "viam.proto.app.robot": module is installed, but missing library stubs or py.typed marker  [import-untyped]
src/config/config.py:1: error: Skipping analyzing "viam.proto.app.robot": module is installed, but missing library stubs or py.typed marker  [import-untyped]
```
These errors occur despite all the type annotations in the SDK.

The solution: in my virtual environment, I ran `touch venv/lib/python3.12/site-packages/viam/py.typed`, and all those errors went away. This works because of [PEP561](https://peps.python.org/pep-0561/), which says "Package maintainers who wish to support type checking of their code MUST add a marker file named `py.typed` to their package"

This PR hopefully does the same thing to the official version. However, I'm unsure how to test this out.
  • Loading branch information
penguinland authored Feb 12, 2025
1 parent 5b4d8e2 commit b092a73
Showing 1 changed file with 0 additions and 0 deletions.
Empty file added src/viam/py.typed
Empty file.

0 comments on commit b092a73

Please sign in to comment.