Skip to content

Enable static type checking for our published Python libraries #240

@jtherrmann

Description

@jtherrmann

Jira: https://asfdaac.atlassian.net/browse/TOOL-3457

Note: The above link is accessible only to members of ASF.


Although we have added our mypy workflow to all of our Python repos, including our distributed packages such as the hyp3-sdk (see our Releasing HyP3 SDK and other packages wiki article for a complete list), we haven't yet enabled library type support for our distributed packages, so if someone imports one of our modules in their code (e.g. from hyp3_sdk import HyP3), they'll get a missing library stubs or py.typed marker error and the imported module will default to type Any (dynamic typing).

From Creating PEP 561 compatible packages, I think enabling static type checking for our published libraries is just:

  1. Ensure that all public functions and classes within the package module have type annotations.
  2. Add a py.typed file to the package directory.

Also see https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker

Metadata

Metadata

Assignees

No one assigned

    Labels

    Jira BugCreate a Jira Bug for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions