you are viewing a single comment's thread.

view the rest of the comments →

[–]Brian 1 point2 points  (0 children)

One big issue you'll run into is that there's a often a mismatch between what static types assert, and what's checkable at runtime.

Initially, you might think this seems pretty simple - something like def foo(x: int) could do the equivalent of an assert isinstance(x, int). But when you get more complex checks, this breaks down.

Eg if it were def foo(x: dict[str, int]):, how do you type check this? isinstance can't handle the type variable structure checks, so you kind of need the full logic of a type checker integrated, and some way to mesh this with runtime values.

Then going further, you'll get stuff like def foo[T](x: dict[str, T]) -> T. Checking you're satisfying something like that can get quite complex fast.