Skip to content

Type annotations aren't discoverable #50

Closed
@DMRobertson

Description

@DMRobertson

#49 added annotations. But mypy won't go looking for them unless we mark the module as having annotations:

$ pip show canonicaljson | \grep ^Version
Version: 1.6.1
$ grep canonicaljson mypy.ini
$ mypy
synapse/__init__.py:67: error: Skipping analyzing "canonicaljson": module is installed, but missing library stubs or py.typed marker  [import]
synapse/__init__.py:67: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

We need a py.typed marker file, but there's no way to do that for single-file modules. https://peps.python.org/pep-0561/#packaging-type-information writes:

This PEP does not support distributing typing information as part of module-only distributions or single-file modules within namespace packages.

The single-file module should be refactored into a package and indicate that the package supports typing [by including a py.typed marker file].

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions