Registry /
testing / flake8-class-attributes-order
An extension for Flake8 that enforces a consistent order for attributes within Python classes. It analyzes various attribute types, including docstrings, properties, methods, nested classes, and constants, and can also detect Django model fields. The current version is 0.3.0, and it maintains an active release cadence with regular updates.
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.7MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.9s · import 0.000s · 20MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Flake8 plugins are typically discovered and loaded automatically upon installation; direct Python 'import' statements for the plugin's checks are not used in user code.
Install 'flake8-class-attributes-order'; it's automatically discovered by Flake8.
To use `flake8-class-attributes-order`, first install it. Then, run `flake8` as you normally would. The plugin automatically integrates. You can configure the order or enable strict mode via a configuration file such as `setup.cfg` or `.flake8`.
import os
# Create a dummy python file for flake8 to check
with open('my_module.py', 'w') as f:
f.write("""class MyClass:
FOO = 1
def __init__(self):
self.bar = 2
def method_a(self):
pass
""")
# Create a flake8 configuration file to enable strict mode (optional, but good for demo)
with open('setup.cfg', 'w') as f:
f.write("[flake8]\nuse_class_attributes_order_strict_mode = True\n")
# Run flake8. Note: flake8's exit code is non-zero if errors are found.
# We use os.system for demonstration; in a real CI, you'd just run 'flake8'.
print("Running flake8 without strict mode (default order):")
os.system("flake8 my_module.py")
print("\nRunning flake8 with strict mode (via setup.cfg):")
os.system("flake8 my_module.py")
# Clean up
os.remove('my_module.py')
os.remove('setup.cfg')
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.