Skip to content

Offer runtime type checking #48

@jszopi

Description

@jszopi

An Any type can easily slip into library functions, whether due to user or library code. As conjectured in Issue #44, a single Any can allow silent but serious library misuse, only to be discovered at runtime (if at all). Further, I can't expect all users to type-annotate their code and run mypy --strict, leaving even more room for incorrect types being passed in to the library.

Runtime type checking based on PEP 484 annotations is possible. I hope there will be no code changes required. The checks will add runtime overhead, so it must be possible for the users to switch them off. Once this is implemented, the documentation on static type checking should be simplified or even largely removed for the benefit of unfamiliar users. The checks should always be on for unit tests.

The only library I'm aware of is pydantic, but I have yet to research alternatives.

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