matrix-org / python-canonicaljson

Canonical JSON
Apache License 2.0
31 stars 15 forks source link

Type annotations aren't discoverable #50

Closed DMRobertson closed 1 year ago

DMRobertson commented 2 years ago

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].

DMRobertson commented 2 years ago

Fix here is to make this a proper package

Edit: for bonus points, update Synapse to