Remix.run Logo
nephanth 4 days ago

Python has static typechecking which, while not perfect, works pretty well as long as you're not actually trying to circumvent it (or manipulating things "too dynamically")

eru 4 days ago | parent [-]

I think Python actually has multiple, different static typechecking systems, depending on which checker you use.

Python itself only gives you type annotations, but doesn't specify what they are supposed to mean.

(I think. Please correct me if I am wrong.)

nephanth 3 days ago | parent [-]

You are slightly wrong.

Python does allow you to put anything in annotations. ( pep 3107 that defines type annotations says that explicitly [1]).

But it also defines a type checking annotations, which is a specific convention for using pep 3107 annotations. Type annotations were introduced in PEP 484 and updated in a lot of subsequent peps. The python typing system is fully specified in [3].

It does have several implementations, although the reference implementation is mypy

[1]: https://peps.python.org/pep-3107/#rejected-proposals

[2]: https://peps.python.org/pep-0484/

[3]: https://typing.python.org/en/latest/spec/index.html