CodeQL documentation

First parameter of a class method is not named ‘cls’

ID: py/not-named-cls
Kind: problem
Security severity: 
Severity: recommendation
Precision: high
Tags:
   - maintainability
   - readability
   - convention
   - quality
Query suites:
   - python-security-and-quality.qls

Click to see the query in the CodeQL repository

The first parameter of a class method (including certain special methods such as __new__), or a method of a metaclass, should be named cls.

Recommendation

Ensure that the first parameter of class methods is named cls, as recommended by the style guidelines in PEP 8.

Example

In the following example, the first parameter of the class method make is named self instead of cls.

class Entry(object):
    @classmethod
    def make(self):
        return Entry()

References

  • © GitHub, Inc.
  • Terms
  • Privacy
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy