Add strict_override_decorator option (PEP 698)#15512
Conversation
8ec9cb4 to
0827dcd
Compare
This comment has been minimized.
This comment has been minimized.
emmatyping
left a comment
There was a problem hiding this comment.
One minor wording suggestion but I think this looks good otherwise!
0827dcd to
de4590e
Compare
This comment has been minimized.
This comment has been minimized.
de4590e to
6e40627
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Pushed a new update. The error message now includes the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for the PR! Looks good overall, some suggestions below. This is an important feature to have in mypy.
|
|
||
| [case requireExplicitOverrideMultipleInheritance] | ||
| # flags: --strict-override-decorator --python-version 3.12 | ||
| from typing import override |
There was a problem hiding this comment.
Test using override imported from typing_extensions on an older Python version?
There was a problem hiding this comment.
I rather not do that. Since none of our test fixtures use @override, we inadvertently get errors for those as well. That's also why I added a separate fixture for these test cases with just enough definitions and no accidental overrides. I would have to do the same just for the typing_extensions fixture.
There is also a test case for an unused @override already. As this PR doesn't change the decorator parsing, it probably fine to skip it.
mypy/test-data/unit/check-functions.test
Lines 2937 to 2947 in 67cc059
|
Thanks for the review @JukkaL! Using a new error code instead of a cmd line option does make sense. The change was fairly strait forward. With that I also updated the documentation and added a whole new section in For now I used |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for the updates, looks good!
Add the strict mode for PEP 698.
Closes: #14072