Missing cls in class method

Class methods should take cls as the first argument.

The @classmethod decorator converts the method to a class method.

When the class method is called, Python will implicitly pass in the class as the first argument, just like how an instance method receives the instance (self, by convention).

While it is true that the first argument could be called anything, Python should be written to be read, and Python developers expect the first argument of class methods to be named cls.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

code-review-doctorbotsuggested changes just now
models.py
1
+
class FooBarClass:
2
+
    @classmethod
3
+
    def from_dict(self):

Class methods should take cls as the first argument.

Read more
Suggested changes
-
    def from_dict(self):
+
    def from_dict(cls):
Commit suggestion
4
+
        pass
Update models.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.