4 ms·
> Said another way, patterns which were once Pythonic are now discouraged by the type system (or, mypy I suppose, since the door is still open for other type ch
by dragonwriter 6y ago
> Said another way, patterns which were once Pythonic are now discouraged by the type system (or, mypy I suppose, since the door is still open for other type checkers to emerge).
There are several typecheckers, and while they are at slightly different points, they evolving together and together with the core typing library.
> Duck typing. I was taught that's Pythonic, yet mypy really only accepts nominal subtyping i.e. it infers type compatibility from the type hierarchy. There is typing.Protocol
Which entirely undercuts “mypy only accepts...”
> but I've never encountered that in code.
That's a library author issue, not a mypy (or typing, the standard library) issue.
> In both cases, mypy reminds me way more of Java's type system than of Python's
Python’s type system has always supported both nominal and structural subtyping.
> heavily typed Python code often ends up looking like Java.
That's probably because Java (and languages with closely related type systems) are the typed languages most people writing typed Python have prior experience with, so it's where their typing instincts go.