I suspect that from the users' perspective @override is too similar to @overload and thus easy to mistype or just use by accident (and get surprising type errors). Java, Kotlin etc do not require an annotation for overloading, so they don't have this problem.



On Fri, May 20, 2022 at 8:54 PM Mehdi2277 <med2277@gmail.com> wrote:
pyright currently supports this in configuration as a global flag that effectively makes override apply to all classes. reportIncompatibleMethodOverride is setting and I have it on for 100k line codebase and have rarely seen cases where I disagree with rule. I can always use type: ignore if needed. I prefer that solution over an override decorator. Most classes in my codebase I consider overriding and changing supported signature an error. I'd rather make incompatible override case require comment/explanation than mark cases where override rule is enforced.

Mypy also automatically detects incompatible overrides. I can't even see a flag for it so looks like a default rule mypy applies. Here's an example with mypy enforcing rule by default, https://mypy-play.net/?mypy=latest&python=3.10&flags=strict&gist=d3e1a06857e4c6f1c698b7fa89e22f40.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: sergei.a.lebedev@gmail.com