News for hackers. Stuff that matters.
Re:What's New in Python 3.11? by kortex on Monday June 27, 2022 @10:11AM (#31894832)
> 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).

There are no comments on this comment yet.