> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Class Method First Parameter Should Be `cls`

#### Sourcery refactoring id: `class-method-first-arg-name`

#### Description:

Suggests that class methods should rename their first parameter to `cls`.

#### Before:

```python
class Chicken:
    @classmethod
    def from_egg(new, egg):
        with egg.hatch() as chick:
            return new(chick)
```

#### After:

```python
class Chicken:
    @classmethod
    def from_egg(cls, egg):
        with egg.hatch() as chick:
            return cls(chick)
```

#### Explanation:

This is both a very strong convention in Python and an explicit entry in
[PEP-8](https://peps.python.org/pep-0008/#function-and-method-arguments).
Adhering to it improves code consistency and makes it easier for developers to
understand the intention of your code.

See also [`instance-method-first-arg-name`](/reference/refactorings/python/instance-method-first-arg-name/)
