flake8-class-attributes-order
A flake8 extension that checks classes attributes order
What it is and what it does
This package is a flake8 plugin that validates the internal structure of Python classes by enforcing a consistent order for attributes, methods, and nested elements. It recognizes different attribute types—docstrings, properties, static methods, class methods, nested classes, constants, fields, and regular methods—and checks that they appear in a defined sequence. By default it expects `__new__` and `__init__` first, followed by other magic methods, then properties, static methods, class methods, and regular methods, with protected and private variants ordered separately.
Beyond ordering, it also detects class-level logic (like conditional expressions or attribute modifications) that should typically live in `__init__` instead. The tool is configurable: you can use a strict mode that separates protected and private variants into their own sections, or manually define your own attribute order. It reports violations as CCE001 (wrong order) and CCE002 (class-level expression) errors that integrate into your flake8 workflow.
Use it for:
- Enforce consistent class structure across a large codebase to improve readability and maintainability.
- Catch Django model fields and methods that are out of conventional order in model definitions.
- Detect class-level logic (e.g., widget configuration) that belongs in `__init__` but was placed at class scope.
- Validate that nested classes like `Meta` appear in the expected position within their parent class.
- Integrate class-structure validation into CI/CD pipelines alongside other flake8 checks.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 extension that enforces a configurable order for class attributes, methods, and nested elements, and detects class-level logic that should be in `__init__`.
Yes, if you value consistent class organization and your team can tolerate aging maintenance. The plugin is stable, has no known vulnerabilities, and solves a real code-style problem. However, verify compatibility with your current flake8 version before adopting. Best suited for teams that already use flake8 and want to standardize class layouts.
Install
flake8-class-attributes-order on PyPI
pip
pip install flake8-class-attributes-orderuv
uv add flake8-class-attributes-orderpoetry
poetry add flake8-class-attributes-orderInstalling flake8-class-attributes-order
Before you install
Installs with minimal friction—only two runtime dependencies (flake8 and typing-extensions). Maintenance is aging: last release was 512 days ago, though the repository remains active with a recent commit.
License in practice
MIT license permits unrestricted use, modification, and distribution with only attribution required. No licensing restrictions on commercial or private projects.
Quickstart
pip install flake8-class-attributes-order
# Then run flake8 on your code:
flake8 your_file.py
# Configure in setup.cfg or .flake8:
# [flake8]
# use_class_attributes_order_strict_mode = True
Requires Python 3.9 or later and an existing flake8 installation.
Verify before relying
- Whether the aging maintenance status affects compatibility with the latest flake8 versions.
- Performance impact on large codebases with many classes.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — flake8, typing-extensions |
| Maintenance | aging — 512 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 363,191/month — #7,226 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_class_attributes_order-0.3.0-py3-none-any.whl
Keywords: flake8
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
flake8-annotations-complexityA flake8 plugin that flags type annotations…
permissive · top 15,000 on PyPI
pep8-namingA flake8 plugin that checks Python code for…
permissive · top 5,000 on PyPI
abstractcpAllows you to define abstract class properties…
permissive · top 15,000 on PyPI
flake8-functionsA flake8 extension that enforces function-level…
permissive · top 15,000 on PyPI
flake8-plugin-utilsProvides base classes and utilities for writing…
permissive · top 5,000 on PyPI
overridesProvides a @override decorator that validates…
permissive · top 1,000 on PyPI
flake8-unused-argumentsA flake8 plugin that detects unused function…
permissive · top 15,000 on PyPI
flake8-annotationsA Flake8 plugin that enforces PEP 3107-style…
permissive · top 15,000 on PyPI
flake8-expression-complexityA flake8 extension that detects overly complex…
permissive · top 15,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI