flake8-classmethod-staticmethod
flake8 plugin that checks rules regarding the staticmethod and classmethod decorators.
Options
The plugin offers one flag, --select_csm1, accepting a list of error
codes (see below) to be enabled. By default, the enabled errors
are CSM101 and CSM131.
Error Codes
CSM100
@staticmethod should not be used.
CSM101
A method marked as @staticmethod should not reference the class it
is defined in. Use @classmethod otherwise.
Bad
class MyClass:
@staticmethod
def my_name():
return MyClass.__name__
Good
class MyClass:
@classmethod
def my_name(cls):
return cls.__name__
CSM102
Do not inherit and override a method marked as @staticmethod.
Bad
class MyClass:
@staticmethod
def my_name():
return "MyClass"
class MyChild:
@staticmethod
def my_name():
return "MyChild"
Good
class MyClass:
@classmethod
def my_name(cls):
return cls.__name__
CSM130
@classmethod should not be used.
CSM131
A method marked as @classmethod should access the parameter cls.
Use @staticmethod otherwise.
A special case that is exempt is a method that has a call to super().
Bad
class MyClass:
@classmethod
def my_name(cls):
return "MyClass"
Good
class MyClass:
@staticmethod
def my_name():
return "MyClass"
CSM132
A method marked as @classmethod should not reference the class it
is defined in. Use the cls parameter.
class MyClass:
@classmethod
def my_name(cls):
return MyClass.__name__
Good
class MyClass:
@classmethod
def my_name(cls):
return cls.__name__
Metadata
Release files for flake8-classmethod-staticmethod 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flake8_classmethod_staticmethod-2.1.tar.gz | 4.6 kB | Without provenance | Details for flake8_classmethod_staticmethod-2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flake8_classmethod_staticmethod-2.1-py3-none-any.whl | Python 3 | none | any | Details for flake8_classmethod_staticmethod-2.1-py3-none-any.whl |
Total release size: 9.4 kB
Release files / flake8_classmethod_staticmethod-2.1.tar.gz
| Download URL | flake8_classmethod_staticmethod-2.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26eba8e11e44f7f6a41cca49bf875e3e7d1ef8b06de84ebf496bb9b6845d3d52
|
|
BLAKE2b-256 checksum How to use checksums |
cd5e35b53a5fb9e490260365b03443065b68221d5596970579807bf560e37bf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / flake8_classmethod_staticmethod-2.1-py3-none-any.whl
| Download URL | flake8_classmethod_staticmethod-2.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44ca4822be9e403456d650c3edba0b2805dcd51f10dbe5bde05b8b104ffcd74f
|
|
BLAKE2b-256 checksum How to use checksums |
2cefb7292f6a3146d86bd2be38ec35db5c53116f4511b4ed92d585c06ef46b97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Security for flake8-classmethod-staticmethod 2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.