---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
UP008 [*] Use `super()` instead of `super(__class__, self)`
  --> UP008.py:17:23
   |
16 |     def wrong(self):
17 |         parent = super(Child, self)  # wrong
   |                       ^^^^^^^^^^^^^
18 |         super(Child, self).method  # wrong
19 |         super(
   |
help: Remove `super()` parameters
   |
16 |     def wrong(self):
   -         parent = super(Child, self)  # wrong
17 +         parent = super()  # wrong
18 |         super(Child, self).method  # wrong
   |

UP008 [*] Use `super()` instead of `super(__class__, self)`
  --> UP008.py:18:14
   |
16 |     def wrong(self):
17 |         parent = super(Child, self)  # wrong
18 |         super(Child, self).method  # wrong
   |              ^^^^^^^^^^^^^
19 |         super(
20 |             Child,
   |
help: Remove `super()` parameters
   |
17 |         parent = super(Child, self)  # wrong
   -         super(Child, self).method  # wrong
18 +         super().method  # wrong
19 |         super(
   |

UP008 [*] Use `super()` instead of `super(__class__, self)`
  --> UP008.py:19:14
   |
17 |           parent = super(Child, self)  # wrong
18 |           super(Child, self).method  # wrong
19 |           super(
   |  ______________^
20 | |             Child,
21 | |             self,
22 | |         ).method()  # wrong
   | |_________^
   |
help: Remove `super()` parameters
   |
18 |         super(Child, self).method  # wrong
   -         super(
   -             Child,
   -             self,
   -         ).method()  # wrong
19 +         super().method()  # wrong
20 |
   |

UP008 [*] Use `super()` instead of `super(__class__, self)`
  --> UP008.py:36:14
   |
34 | class MyClass(BaseClass):
35 |     def normal(self):
36 |         super(MyClass, self).f()  # can use super()
   |              ^^^^^^^^^^^^^^^
37 |         super().f()
   |
help: Remove `super()` parameters
   |
35 |     def normal(self):
   -         super(MyClass, self).f()  # can use super()
36 +         super().f()  # can use super()
37 |         super().f()
   |

UP008 [*] Use `super()` instead of `super(__class__, self)`
  --> UP008.py:71:18
   |
70 |         def inner_argument(self):
71 |             super(MyClass, self).f()  # can use super()
   |                  ^^^^^^^^^^^^^^^
72 |             super().f()
   |
help: Remove `super()` parameters
   |
70 |         def inner_argument(self):
   -             super(MyClass, self).f()  # can use super()
71 +             super().f()  # can use super()
72 |             super().f()
   |

UP008 [*] Use `super()` instead of `super(__class__, self)`
  --> UP008.py:98:14
   |
96 | class DataClass:
97 |     def normal(self):
98 |         super(DataClass, self).f()  # Error
   |              ^^^^^^^^^^^^^^^^^
99 |         super().f()  # OK
   |
help: Remove `super()` parameters
   |
97 |     def normal(self):
   -         super(DataClass, self).f()  # Error
98 +         super().f()  # Error
99 |         super().f()  # OK
   |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:116:14
    |
114 | class B(A):
115 |     def bar(self):
116 |         super(__class__, self).foo()
    |              ^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
115 |     def bar(self):
    -         super(__class__, self).foo()
116 +         super().foo()
117 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:137:14
    |
135 |   class ClassForCommentEnthusiasts(BaseClass):
136 |       def with_comments(self):
137 |           super(
    |  ______________^
138 | |             # super helpful comment
139 | |             ClassForCommentEnthusiasts,
140 | |             self
141 | |         ).f()
    | |_________^
142 |           super(
143 |               ClassForCommentEnthusiasts,
    |
help: Remove `super()` parameters
    |
136 |     def with_comments(self):
    -         super(
    -             # super helpful comment
    -             ClassForCommentEnthusiasts,
    -             self
    -         ).f()
137 +         super().f()
138 |         super(
    |
note: This is an unsafe fix and may change runtime behavior

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:142:14
    |
140 |               self
141 |           ).f()
142 |           super(
    |  ______________^
143 | |             ClassForCommentEnthusiasts,
144 | |             # even more helpful comment
145 | |             self
146 | |         ).f()
    | |_________^
147 |           super(
148 |               ClassForCommentEnthusiasts,
    |
help: Remove `super()` parameters
    |
141 |         ).f()
    -         super(
    -             ClassForCommentEnthusiasts,
    -             # even more helpful comment
    -             self
    -         ).f()
142 +         super().f()
143 |         super(
    |
note: This is an unsafe fix and may change runtime behavior

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:147:14
    |
145 |               self
146 |           ).f()
147 |           super(
    |  ______________^
148 | |             ClassForCommentEnthusiasts,
149 | |             self
150 | |             # also a comment
151 | |         ).f()
    | |_________^
    |
help: Remove `super()` parameters
    |
146 |         ).f()
    -         super(
    -             ClassForCommentEnthusiasts,
    -             self
    -             # also a comment
    -         ).f()
147 +         super().f()
148 |
    |
note: This is an unsafe fix and may change runtime behavior

UP008 Use `super()` instead of `super(__class__, self)`
   --> UP008.py:157:21
    |
155 | class Ord(int):
156 |     def __len__(self):
157 |         return super(Ord, self, uhoh=True, **{"error": True}).bit_length()
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158 |
159 | class ExampleWithKeywords:
    |
help: Remove `super()` parameters

UP008 Use `super()` instead of `super(__class__, self)`
   --> UP008.py:161:14
    |
159 | class ExampleWithKeywords:
160 |     def method1(self):
161 |         super(ExampleWithKeywords, self, invalid=True).some_method()  # Should emit diagnostic but NOT be fixed
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162 |     
163 |     def method2(self):
    |
help: Remove `super()` parameters

UP008 Use `super()` instead of `super(__class__, self)`
   --> UP008.py:164:14
    |
163 |     def method2(self):
164 |         super(ExampleWithKeywords, self, **{"kwarg": "value"}).some_method()  # Should emit diagnostic but NOT be fixed
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
165 |     
166 |     def method3(self):
    |
help: Remove `super()` parameters

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:167:14
    |
166 |     def method3(self):
167 |         super(ExampleWithKeywords, self).some_method()  # Should be fixed - no keywords
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
168 |
169 | # See: https://github.com/astral-sh/ruff/issues/19357
    |
help: Remove `super()` parameters
    |
166 |     def method3(self):
    -         super(ExampleWithKeywords, self).some_method()  # Should be fixed - no keywords
167 +         super().some_method()  # Should be fixed - no keywords
168 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:178:23
    |
176 |     def f(self):
177 |         if False: __class__ # Python injects __class__ into scope
178 |         builtins.super(ChildD1, self).f()
    |                       ^^^^^^^^^^^^^^^
179 |
180 | class ChildD2(ParentD):
    |
help: Remove `super()` parameters
    |
177 |         if False: __class__ # Python injects __class__ into scope
    -         builtins.super(ChildD1, self).f()
178 +         builtins.super().f()
179 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:183:23
    |
181 |     def f(self):
182 |         if False: super # Python injects __class__ into scope
183 |         builtins.super(ChildD2, self).f()
    |                       ^^^^^^^^^^^^^^^
184 |
185 | class ChildD3(ParentD):
    |
help: Remove `super()` parameters
    |
182 |         if False: super # Python injects __class__ into scope
    -         builtins.super(ChildD2, self).f()
183 +         builtins.super().f()
184 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:187:23
    |
185 | class ChildD3(ParentD):
186 |     def f(self):
187 |         builtins.super(ChildD3, self).f()
    |                       ^^^^^^^^^^^^^^^
188 |         super # Python injects __class__ into scope
    |
help: Remove `super()` parameters
    |
186 |     def f(self):
    -         builtins.super(ChildD3, self).f()
187 +         builtins.super().f()
188 |         super # Python injects __class__ into scope
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:193:29
    |
191 | class ChildD4(ParentD):
192 |     def f(self):
193 |         builtins_alias.super(ChildD4, self).f()
    |                             ^^^^^^^^^^^^^^^
194 |         super # Python injects __class__ into scope
    |
help: Remove `super()` parameters
    |
192 |     def f(self):
    -         builtins_alias.super(ChildD4, self).f()
193 +         builtins_alias.super().f()
194 |         super # Python injects __class__ into scope
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:200:23
    |
198 |         super = 1
199 |         super # Python injects __class__ into scope
200 |         builtins.super(ChildD5, self).f()
    |                       ^^^^^^^^^^^^^^^
201 |
202 | class ChildD6(ParentD):
    |
help: Remove `super()` parameters
    |
199 |         super # Python injects __class__ into scope
    -         builtins.super(ChildD5, self).f()
200 +         builtins.super().f()
201 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:206:23
    |
204 |         super: "Any"
205 |         __class__ # Python injects __class__ into scope
206 |         builtins.super(ChildD6, self).f()
    |                       ^^^^^^^^^^^^^^^
207 |
208 | class ChildD7(ParentD):
    |
help: Remove `super()` parameters
    |
205 |         __class__ # Python injects __class__ into scope
    -         builtins.super(ChildD6, self).f()
206 +         builtins.super().f()
207 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:212:23
    |
210 |         def x():
211 |             __class__ # Python injects __class__ into scope
212 |         builtins.super(ChildD7, self).f()
    |                       ^^^^^^^^^^^^^^^
213 |
214 | class ChildD8(ParentD):
    |
help: Remove `super()` parameters
    |
211 |             __class__ # Python injects __class__ into scope
    -         builtins.super(ChildD7, self).f()
212 +         builtins.super().f()
213 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:219:23
    |
217 |             super = 1
218 |         super # Python injects __class__ into scope
219 |         builtins.super(ChildD8, self).f()
    |                       ^^^^^^^^^^^^^^^
220 |
221 | class ChildD9(ParentD):
    |
help: Remove `super()` parameters
    |
218 |         super # Python injects __class__ into scope
    -         builtins.super(ChildD8, self).f()
219 +         builtins.super().f()
220 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:226:23
    |
224 |             __class__ = 1
225 |         __class__ # Python injects __class__ into scope
226 |         builtins.super(ChildD9, self).f()
    |                       ^^^^^^^^^^^^^^^
227 |
228 | class ChildD10(ParentD):
    |
help: Remove `super()` parameters
    |
225 |         __class__ # Python injects __class__ into scope
    -         builtins.super(ChildD9, self).f()
226 +         builtins.super().f()
227 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:233:23
    |
231 |             __class__ = 1
232 |         super # Python injects __class__ into scope
233 |         builtins.super(ChildD10, self).f()
    |                       ^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
232 |         super # Python injects __class__ into scope
    -         builtins.super(ChildD10, self).f()
233 +         builtins.super().f()
234 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:342:18
    |
340 |     class Inner(Base):
341 |         def __init__(self, foo):
342 |             super(Outer.Inner, self).__init__(foo)  # UP008: matches enclosing class chain
    |                  ^^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
341 |         def __init__(self, foo):
    -             super(Outer.Inner, self).__init__(foo)  # UP008: matches enclosing class chain
342 +             super().__init__(foo)  # UP008: matches enclosing class chain
343 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:377:22
    |
375 |         class C(Base):
376 |             def __init__(self, foo):
377 |                 super(A.B.C, self).__init__(foo)  # UP008: matches full chain
    |                      ^^^^^^^^^^^^^
378 |
379 | # Mismatched middle segment: Wrong.Inner doesn't match Outer3.Inner
    |
help: Remove `super()` parameters
    |
376 |             def __init__(self, foo):
    -                 super(A.B.C, self).__init__(foo)  # UP008: matches full chain
377 +                 super().__init__(foo)  # UP008: matches full chain
378 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:388:15
    |
386 | class Whitespace(BaseClass):
387 |     def f(self):
388 |         super (Whitespace, self).f()  # can use super()
    |               ^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
387 |     def f(self):
    -         super (Whitespace, self).f()  # can use super()
388 +         super ().f()  # can use super()
389 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:395:22
    |
393 |         class LocalInner(BaseClass):
394 |             def f(self):
395 |                 super(LocalOuter.LocalInner, self).f()  # can use super()
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
394 |             def f(self):
    -                 super(LocalOuter.LocalInner, self).f()  # can use super()
395 +                 super().f()  # can use super()
396 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:399:27
    |
398 | class LambdaMethod(BaseClass):
399 |     f = lambda self: super(LambdaMethod, self).f()  # can use super()
    |                           ^^^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
398 | class LambdaMethod(BaseClass):
    -     f = lambda self: super(LambdaMethod, self).f()  # can use super()
399 +     f = lambda self: super().f()  # can use super()
400 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:405:14
    |
403 |     @classmethod
404 |     def f(cls):
405 |         super(ClassMethod, cls).f()  # can use super()
    |              ^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
404 |     def f(cls):
    -         super(ClassMethod, cls).f()  # can use super()
405 +         super().f()  # can use super()
406 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:410:14
    |
408 | class AsyncMethod(BaseClass):
409 |     async def f(self):
410 |         super(AsyncMethod, self).f()  # can use super()
    |              ^^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
409 |     async def f(self):
    -         super(AsyncMethod, self).f()  # can use super()
410 +         super().f()  # can use super()
411 |
    |

UP008 [*] Use `super()` instead of `super(__class__, self)`
   --> UP008.py:416:19
    |
414 |     class Inner(BaseClass):
415 |         def f(self):
416 |             super (OuterWithWhitespace.Inner, self).f()  # can use super()
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: Remove `super()` parameters
    |
415 |         def f(self):
    -             super (OuterWithWhitespace.Inner, self).f()  # can use super()
416 +             super ().f()  # can use super()
    |
