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
{{ message }}
Repository navigation
False positive for class method without Self annotation #15771
Mypy reports an error for method save1 (without annotation) but no errors for save2 and save3 (with different Self annotations), despite their (almost) identical function bodies:
fromcopyimportdeepcopyfromtypingimportSelfclassA:
states: list[Self]
defsave1(self) ->None:
self.states.append(deepcopy(self)) # error: Argument 1 to "append" of "list" has incompatible type "A"; expected "Self" [arg-type]defsave2(self: Self) ->None:
self.states.append(deepcopy(self))
defsave3(self) ->Self:
self.states.append(deepcopy(self))
returnself
This bug might be related to #15529 but is not fixed by #15541.
Activity