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
super(MyClass, arg) can only be replaced with super() if arg is the first argument to a function that’s defined within class MyClass. In other cases, the SPR001 diagnostic from ruff (and from flake8-super, I guess) is a false positive.
Some examples:
classBaseClass:
deff(self):
passdefdefined_outside(self):
super(MyClass, self).f() # CANNOT use super()classMyClass(BaseClass):
defnormal(self):
super(MyClass, self).f() # can use super()super().f()
defdifferent_argument(self, other):
super(MyClass, other).f() # CANNOT use super()defcomprehension_scope(self):
[super(MyClass, self).f() forxin [1]] # CANNOT use super()definner_functions(self):
defouter_argument():
super(MyClass, self).f() # CANNOT use super()definner_argument(self):
super(MyClass, self).f() # can use super()super().f()
outer_argument()
inner_argument(self)
definner_class(self):
classInnerClass:
super(MyClass, self).f() # CANNOT use super()defmethod(inner_self):
super(MyClass, self).f() # CANNOT use super()InnerClass().method()
defined_outside=defined_outsideMyClass().normal()
MyClass().different_argument(MyClass())
MyClass().comprehension_scope()
MyClass().inner_functions()
MyClass().inner_class()
MyClass().defined_outside()
super(MyClass, arg)
can only be replaced withsuper()
ifarg
is the first argument to a function that’s defined withinclass MyClass
. In other cases, theSPR001
diagnostic from ruff (and from flake8-super, I guess) is a false positive.Some examples:
Some false positives in the wild:
https://github.com/zulip/zulip/blob/5.6/zerver/lib/test_helpers.py#L167
https://github.com/zulip/zulip/blob/5.6/zerver/tests/test_auth_backends.py#L326
The text was updated successfully, but these errors were encountered: