Skip to content

UP008 false negative on super(__class__, self) #18477

@dscorbett

Description

@dscorbett

Summary

The documentation for super-call-with-parameters (UP008) says:

In Python 3, super can be invoked without any arguments when: (1) the first argument is __class__, and (2) the second argument is equivalent to the first argument of the enclosing method.

However, the rule only applies when the first argument is the class by name. UP008 should check for __class__ too.

$ cat >up008.py <<'# EOF'
class A:
    def foo(self):
        pass
class B(A):
    def bar(self):
        super(__class__, self).foo()
# EOF

$ ruff --isolated check up008.py --select UP008
All checks passed!

Version

ruff 0.11.12 (aee3af0 2025-05-29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions especially welcomeruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions