Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

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

ID: py/not-named-clsKind: problemSecurity severity: Severity: recommendationPrecision: highTags:   - maintainability   - readability   - convention   - qualityQuery 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 namedcls.

Recommendation

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

Example

In the following example, the first parameter of the class methodmake is namedself instead ofcls.

classEntry(object):@classmethoddefmake(self):returnEntry()

References


[8]ページ先頭

©2009-2025 Movatter.jp