--- id: flake8-class-attributes-order version: "0.3.0" license: MIT license_treatment: permissive maintenance: aging --- # flake8-class-attributes-order — A flake8 extension that checks classes attributes order License: permissive · Maintenance: aging · Downloads: 363.2K/mo ## 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 above — 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 pip install flake8-class-attributes-order uv add flake8-class-attributes-order poetry add flake8-class-attributes-order ## Installing 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_current - Install friction: low - Maintenance: aging - Downloads: 363.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags flake8 class attribute order, python class structure linter, enforce method ordering, class organization checker, flake8 code style extension, class attribute validation, python class layout checker, flake8-plugin, code-style, class-structure [View on SkillFed](https://skillfed.io/packages/flake8-class-attributes-order) · [View on PyPI](https://pypi.org/project/flake8-class-attributes-order/)