|
|
|
|
|
by mwt
497 days ago
|
|
I'm a little surprised to see you dismiss type-checkers disagreeing with each other - there are more than a few cases of mypy and pyright disagreeing and brushing them aside as rare enough to be irrelevant is in conflict with my experience over the years. I'm happy you believe that the community can converge on unified standards - I wish I shared the optimism - but that's not where we're currently at and years-long efforts don't help me now. (For example, I'd love to use PEP 695 generics since I found a use case for them around 18 months ago but I can't until I can get away with not supporting 3.11, which is years out.) Maybe everything is perfect in 2028 or so - I'd be thrilled - but that doesn't help the pitch for annotations being a value add for people who are worried about the current jobs. |
|
pep695 is a good example of how the spec is still evolving to try and make the explicit type system work better for python developers. dataclass transforms are perhaps an even better example - that's a pattern that is very specific to python and based on real world, non-typing-related ways in which people use the language, and which they wanted the annotation system to cover, and there was a collaborative effort to develop a way to do it.
also note that there are escape hatches like error suppression (e.g. if pyright likes some code but mypy wrongly thinks it's a type error, you can add a comment so that mypy ignores that one error while continuing to have pyright check it) and typing.cast (which is a directive all the type checkers honour, to say "trust me, this variable has this particular type whether or not you can verify it statically").
another thing to consider is that having type checking work interactively in the IDE is something a lot of people want, and pyright was developed specifically to support that feature. mypy, pytype, and pyre were all architected as batch type checkers, i.e. they need to run on a complete program as a standalone process, and it would have been anywhere from difficult to impossible to get them to support the type of incremental checking an IDE requires.