-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
When the first argument to super
in a method is a local variable named __class__
, super-call-with-parameters
(UP008) should not apply. Example:
$ cat >up008.py <<'# EOF'
class A:
def f(self):
return 1
class B(A):
def f(self):
return 2
class C(B):
def f(self):
__class__ = B
return super(__class__, self).f()
print(C().f())
# EOF
$ python up008.py
1
$ ruff --isolated check up008.py --select UP008 --unsafe-fixes --fix
Found 1 error (1 fixed, 0 remaining).
$ python up008.py 2>&1 | tail -n 1
RuntimeError: super(): __class__ cell not found
This isn’t a problem in the usual case where __class__
is nonlocal, whether explicitly via nonlocal __class__
or implicitly by not being assigned to.
Version
ruff 0.13.1 (706be0a 2025-09-18)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working