flake8-define-class-attributes
Check that class attributes are defined at the "top level" of your class. This is in the same spirit as Pylint's W0201 (attribute-defined-outside-init) error, expanded to allow attribute declaration at the class level.
For example:
Failing Code:
class Spaceship:
def reset_location(self) -> None:
self.xy = (0, 0) # CLA001
Passing Code:
class Spaceship:
def __init__(self):
self.xy = (0, 0)
def reset_location(self):
self.xy = (0, 0)
# --OR--
class Spaceship:
xy: tuple[int, int]
def reset_location(self):
self.xy = (0, 0)
When using dataclasses, __post_init__ methods are also considered when checking that an attribute has been defined.
Installation
Install from PyPi with your favorite pip invocation:
$ pip install flake8-define-class-attributes
It will then be run automatically as part of flake8.
You can verify it's being picked up by invoking the following in your shell:
$ flake8 --version
7.3.0 (flake8-define-class-attributes: 0.2.2, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.13.5 on Darwin
Warnings
| ID | Description |
|---|---|
CLA001 |
Attribute <name> not defined prior to assignment |
Python Version Support
Beginning with Python 3.11, a best attempt is made to support Python versions until they reach EOL, after which support will be formally dropped by the next minor or major release of this package, whichever arrives first. The status of Python versions can be found here.
Metadata
Release files for flake8-define-class-attributes 0.2.2
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_define_class_attributes-0.2.2.tar.gz | 6.7 kB | With provenance | Details for flake8_define_class_attributes-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flake8_define_class_attributes-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for flake8_define_class_attributes-0.2.2-py3-none-any.whl |
Total release size: 15.1 kB
Release files / flake8_define_class_attributes-0.2.2.tar.gz
| Download URL | flake8_define_class_attributes-0.2.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
688d65c7fd41ae24804c0c1932e982117fef5c7554d2198821a92854c669a585
|
|
BLAKE2b-256 checksum How to use checksums |
6527e35b2257f6ead574d21b8832b1c2a8c1e6bb221652705bd9754f3b7cf52a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2025.
Transparency logRelease files / flake8_define_class_attributes-0.2.2-py3-none-any.whl
| Download URL | flake8_define_class_attributes-0.2.2-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1a6350467e04ae75a17bee268224c94cbb06da706f9c8c442ee039d9609f7b8
|
|
BLAKE2b-256 checksum How to use checksums |
12b2805880f66deddb3cda86370c6dd23a67288e641e282c0cc18ad9db364d4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2025.
Transparency logSecurity for flake8-define-class-attributes 0.2.2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for flake8_define_class_attributes-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2025.
Transparency logA 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.