3 ms·
> And it's pretty half baked on top (e.g. `a: int = "foo"` goes through the python interpreter without even a warning). Well, yeah, because that's a compile-ti
by kortex 4y ago
> And it's pretty half baked on top (e.g. `a: int = "foo"` goes through the python interpreter without even a warning).
Well, yeah, because that's a compile-time check, not a runtime check. Use Pydantic if you want runtime validations.
> The new type system goes pretty much against the idea of duck typing,
It's very much orthogonal, due to the aforementioned distinction. Type annotations are compile-time. Duck-typing is run-time. You can still type-hint something and then call an attribute that isn't on the interface, and you can suppress the type error with `# type: ignore`. But also, if you know you are using quack(), you probably want foo(duck: Duck).