Skip to content

Towards typing compatibility of this package's public interface (py.typed marker) #998

Open
@sh-at-cs

Description

@sh-at-cs

Issue

This package currently has no PEP-561 py.typed marker, which means that static type checkers like Mypy or Pyright are unable to typecheck usages of it.

What would need to change

A py.typed marker signals to type checkers that a package's public type hints are assumed to be correct and (mostly?) complete, so it should only be added once that's the case.

So some changes may be needed to this project before it makes sense to add one. Maybe we can track these in this issue?

  • Fix type errors that occur in typical usages of this project. I found out about these by manually adding a py.typed file to this library's directory and then using it inside a "typical" Django project, running Mypy in strict mode.
    • Anywhere Column or its subclasses are used, Mypy complains: Call to untyped function "Column" in typed context. To fix this:
      • Add type hints to Column.__init__ and the __init__ methods of its subclasses.
        • As some of these parameters are StrOrPromise types, this probably needs a dependency on django-stubs-ext 😬
      • Make Library.register typed so the @library.register decorator on all these classes doesn't lose cause loss of type information.
    • ... probably more that I don't know about (if anyone finds any, leave a comment and I'll put it here)
  • There should maybe be a "type coverage report" in CI to make sure that changes at least don't decrease type completeness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions