---
source: crates/ruff_linter/src/rules/pep8_naming/mod.rs
---
N804.py:30:27: N804 [*] First argument of a class method should be named `cls`
   |
28 |         ...
29 | 
30 |     def __init_subclass__(self, default_name, **kwargs):
   |                           ^^^^ N804
31 |         ...
   |
   = help: Rename `self` to `cls`

ℹ Unsafe fix
27 27 |     def __new__(cls, *args, **kwargs):
28 28 |         ...
29 29 | 
30    |-    def __init_subclass__(self, default_name, **kwargs):
   30 |+    def __init_subclass__(cls, default_name, **kwargs):
31 31 |         ...
32 32 | 
33 33 |     @classmethod

N804.py:38:56: N804 [*] First argument of a class method should be named `cls`
   |
37 |     @classmethod
38 |     def bad_class_method_with_positional_only_argument(self, x, /, other):
   |                                                        ^^^^ N804
39 |         ...
   |
   = help: Rename `self` to `cls`

ℹ Unsafe fix
35 35 |         ...
36 36 | 
37 37 |     @classmethod
38    |-    def bad_class_method_with_positional_only_argument(self, x, /, other):
   38 |+    def bad_class_method_with_positional_only_argument(cls, x, /, other):
39 39 |         ...
40 40 | 
41 41 | 

N804.py:43:20: N804 [*] First argument of a class method should be named `cls`
   |
42 | class MetaClass(ABCMeta):
43 |     def bad_method(self):
   |                    ^^^^ N804
44 |         pass
   |
   = help: Rename `self` to `cls`

ℹ Unsafe fix
40 40 | 
41 41 | 
42 42 | class MetaClass(ABCMeta):
43    |-    def bad_method(self):
   43 |+    def bad_method(cls):
44 44 |         pass
45 45 | 
46 46 |     def good_method(cls):

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

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

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

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

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

N804.py:70:20: N804 [*] First argument of a class method should be named `cls`
   |
69 | class RenamingInMethodBodyClass(ABCMeta):
70 |     def bad_method(this):
   |                    ^^^^ N804
71 |         this = this
72 |         this
   |
   = help: Rename `this` to `cls`

ℹ Unsafe fix
67 67 |         pass
68 68 | 
69 69 | class RenamingInMethodBodyClass(ABCMeta):
70    |-    def bad_method(this):
71    |-        this = this
72    |-        this
   70 |+    def bad_method(cls):
   71 |+        cls = cls
   72 |+        cls
73 73 | 
74 74 |     def bad_method(this):
75 75 |         self = this

N804.py:74:20: N804 [*] First argument of a class method should be named `cls`
   |
72 |         this
73 | 
74 |     def bad_method(this):
   |                    ^^^^ N804
75 |         self = this
   |
   = help: Rename `this` to `cls`

ℹ Unsafe fix
71 71 |         this = this
72 72 |         this
73 73 | 
74    |-    def bad_method(this):
75    |-        self = this
   74 |+    def bad_method(cls):
   75 |+        self = cls
76 76 | 
77 77 | def func(x):
78 78 |     return x
