PEP 702 (@deprecated): overriding deprecated methods #18085
+137
−38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think some points need discussion before implementing everything neatly, especially regarding overloads. So, my first (untidy) commit focuses on "normal" methods (
testDeprecatedOverriddenMethod
).Is it okay to override a deprecated method with another signature when not using
@override
?My tendency is yes; see
testDeprecatedOverriddenMethod
.Is it desirable that Mypy emits an error for
C.f
in the following case (as it currently does)?My tendency is that no error should be emitted for
C.f
. I did not change this, but it appears to be simple.I am asking because:
PEP 698 does not mention
@overload
. In Mypy, a single@override
for any overload item or the implementation affects the whole overloaded method. This was decided here without any discussions I know of and will likely result in some inconsistencies with the overload item-specific implementation of@deprecated
:I think it would be favourable to neither emit deprecation nor signature-incompatible notes in the given example. (I did not investigate how hard it would be to implement this.
override
anddeprecated
are properties of symbols. But maybe we could just remove some items before doing the checks.)