You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 @override on every overriding method ("strict mode").
I just noticed the Method "<method_name>" is marked as an override, but no base method was found with this name error is categorised under misc instead of override. Is that intended?
There seems to be some issue with the way this plays with --check-untyped-defs, see this playground example:
fromtyping_extensionsimportoverrideclassA:
deff(self, x: int) ->int:
return2classB(A):
@overridedeff(self, x: int): # why `-> int` is not inferred?returnNone# why return type violation is not reported?@overridedefg(self, y): # why "no base method" is not reported?return4
Are there plans for this error code to be included in strict mode any time soon?
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 @override will only be added to the stdlib in Python 3.12.
Activity
tmke8 commentedon Feb 2, 2023
The PEP has now been officially accepted for Python 3.12.
Support for PEP 698 override decorator (#14609)
tmke8 commentedon May 12, 2023
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
@overrideon every overriding method ("strict mode").tmke8 commentedon May 12, 2023
@hauntsaninja , can you reopen this issue? It seems I can't do that.
NeilGirdhar commentedon May 12, 2023
FYI: this discussion may be relevant for whoever implements the flag. 😄
cdce8p commentedon Jun 24, 2023
Just opened #15512 to add a strict flag for method overrides as suggested in the PEP.
Avasam commentedon Jul 10, 2023
I just noticed the
Method "<method_name>" is marked as an override, but no base method was found with this nameerror is categorised undermiscinstead ofoverride. Is that intended?mttbernardini commentedon Jul 12, 2023
There seems to be some issue with the way this plays with
--check-untyped-defs, see this playground example:Add error code "explicit-override" for strict @OverRide mode (PEP 698) (
bersbersbers commentedon Jul 13, 2023
Thanks, this is great! I have already added
enable_error_code = ["explicit-override"]to enable it.Are there plans for this error code to be included in
strictmode any time soon?cdce8p commentedon Jul 13, 2023
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
@overridewill only be added to the stdlib in Python 3.12.johnthagen commentedon Jul 9, 2024
@bersbersbers I opened a tracking issue so that users can track when this is enabled by default in
strictmodeexplicit-overrideby default instrictmode #17511