---
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
---
N804 [*] First argument of a class method should be named `cls`
  --> N804.py:30:27
   |
28 |         ...
29 |
30 |     def __init_subclass__(self, default_name, **kwargs):
   |                           ^^^^
31 |         ...
   |
help: Rename `self` to `cls`
   |
29 |
   -     def __init_subclass__(self, default_name, **kwargs):
30 +     def __init_subclass__(cls, default_name, **kwargs):
31 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

N804 [*] First argument of a class method should be named `cls`
  --> N804.py:38:56
   |
37 |     @classmethod
38 |     def bad_class_method_with_positional_only_argument(self, x, /, other):
   |                                                        ^^^^
39 |         ...
   |
help: Rename `self` to `cls`
   |
37 |     @classmethod
   -     def bad_class_method_with_positional_only_argument(self, x, /, other):
38 +     def bad_class_method_with_positional_only_argument(cls, x, /, other):
39 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

N804 [*] First argument of a class method should be named `cls`
  --> N804.py:43:20
   |
42 | class MetaClass(ABCMeta):
43 |     def bad_method(self):
   |                    ^^^^
44 |         pass
   |
help: Rename `self` to `cls`
   |
42 | class MetaClass(ABCMeta):
   -     def bad_method(self):
43 +     def bad_method(cls):
44 |         pass
   |
note: This is an unsafe fix and may change runtime behavior

N804 First argument of a class method should be named `cls`
  --> N804.py:54:25
   |
53 | class ClsInArgsClass(ABCMeta):
54 |     def cls_as_argument(this, cls):
   |                         ^^^^
55 |         pass
   |
help: Rename `this` to `cls`

N804 First argument of a class method should be named `cls`
  --> N804.py:57:34
   |
55 |         pass
56 |
57 |     def cls_as_pos_only_argument(this, cls, /):
   |                                  ^^^^
58 |         pass
   |
help: Rename `this` to `cls`

N804 First argument of a class method should be named `cls`
  --> N804.py:60:33
   |
58 |         pass
59 |
60 |     def cls_as_kw_only_argument(this, *, cls):
   |                                 ^^^^
61 |         pass
   |
help: Rename `this` to `cls`

N804 First argument of a class method should be named `cls`
  --> N804.py:63:23
   |
61 |         pass
62 |
63 |     def cls_as_varags(this, *cls):
   |                       ^^^^
64 |         pass
   |
help: Rename `this` to `cls`

N804 First argument of a class method should be named `cls`
  --> N804.py:66:23
   |
64 |         pass
65 |
66 |     def cls_as_kwargs(this, **cls):
   |                       ^^^^
67 |         pass
   |
help: Rename `this` to `cls`

N804 [*] First argument of a class method should be named `cls`
  --> N804.py:70:20
   |
69 | class RenamingInMethodBodyClass(ABCMeta):
70 |     def bad_method(this):
   |                    ^^^^
71 |         this = this
72 |         this
   |
help: Rename `this` to `cls`
   |
69 | class RenamingInMethodBodyClass(ABCMeta):
   -     def bad_method(this):
   -         this = this
   -         this
70 +     def bad_method(cls):
71 +         cls = cls
72 +         cls
73 |
   |
note: This is an unsafe fix and may change runtime behavior

N804 [*] First argument of a class method should be named `cls`
  --> N804.py:74:20
   |
72 |         this
73 |
74 |     def bad_method(this):
   |                    ^^^^
75 |         self = this
   |
help: Rename `this` to `cls`
   |
73 |
   -     def bad_method(this):
   -         self = this
74 +     def bad_method(cls):
75 +         self = cls
76 |
   |
note: This is an unsafe fix and may change runtime behavior

N804 First argument of a class method should be named `cls`
  --> N804.py:88:18
   |
86 | class Example:
87 |     @classmethod
88 |     def function(this):
   |                  ^^^^
89 |         cls = 1234
   |
help: Rename `this` to `cls`
