-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support PEP 698 – Override Decorator #14072
Comments
The PEP has now been officially accepted for Python 3.12. |
Closes #14072 This implements support for [PEP 698](https://peps.python.org/pep-0698/), which has recently been accepted for Python 3.12. However, this doesn't yet add the "strict mode" that is recommended in the PEP.
Ah, I shouldn't have linked this issue to the PR because there is still a missing piece: a new flag which enforces the use of |
@hauntsaninja , can you reopen this issue? It seems I can't do that. |
FYI: this discussion may be relevant for whoever implements the flag. 😄 |
Just opened #15512 to add a strict flag for method overrides as suggested in the PEP. |
I just noticed the |
There seems to be some issue with the way this plays with from typing_extensions import override
class A:
def f(self, x: int) -> int:
return 2
class B(A):
@override
def f(self, x: int): # why `-> int` is not inferred?
return None # why return type violation is not reported?
@override
def g(self, y): # why "no base method" is not reported?
return 4 |
#15512) Add the strict mode for [PEP 698](https://peps.python.org/pep-0698/#strict-enforcement-per-project). Closes: #14072
Thanks, this is great! I have already added Are there plans for this error code to be included in |
I don't think that will happen. Just an example, enabling this for Home Assistant would create 11k+ new errors and that's just one project. It'll probably take quite a long time until all code is sufficiently updated, especially given that |
@bersbersbers I opened a tracking issue so that users can track when this is enabled by default in |
PEP 698 adds an
@override
decorator.Todo:
@override
(done in Add support for PEP 698 - override decorator #14609)Related issue: #1888
The text was updated successfully, but these errors were encountered: