skillfed

flake8-class-attributes-order

A flake8 extension that checks classes attributes order

flake8-class-attributes-order v0.3.0 363.2K downloads/30d#7,226 on PyPI60
Permissive license MIT AGING released

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-order

uv

uv add flake8-class-attributes-order

poetry

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 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

Environment :: ConsoleFramework :: Flake8Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: DocumentationTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

flake8 class attribute orderpython class structure linterenforce method orderingclass organization checkerflake8 code style extensionclass attribute validationpython class layout checker
flake8-plugincode-styleclass-structure

More Python Modules packages

idna

Converts domain names between Unicode and…

permissive · top 100 on PyPI

setuptools

Setuptools is a Python build backend and…

permissive · top 100 on PyPI

PyYAML

PyYAML parses and emits YAML 1.1 data format,…

permissive · top 100 on PyPI

pydantic

Pydantic validates Python data structures…

permissive · top 100 on PyPI

annotated-types

Provides reusable metadata objects for use with…

permissive · top 100 on PyPI

typing-inspection

Provides runtime tools to inspect and…

permissive · top 100 on PyPI

flake8-annotations-complexity

A flake8 plugin that flags type annotations…

permissive · top 15,000 on PyPI

pep8-naming

A flake8 plugin that checks Python code for…

permissive · top 5,000 on PyPI

abstractcp

Allows you to define abstract class properties…

permissive · top 15,000 on PyPI

flake8-functions

A flake8 extension that enforces function-level…

permissive · top 15,000 on PyPI

flake8-plugin-utils

Provides base classes and utilities for writing…

permissive · top 5,000 on PyPI

overrides

Provides a @override decorator that validates…

permissive · top 1,000 on PyPI

flake8-unused-arguments

A flake8 plugin that detects unused function…

permissive · top 15,000 on PyPI

flake8-annotations

A Flake8 plugin that enforces PEP 3107-style…

permissive · top 15,000 on PyPI

flake8-expression-complexity

A flake8 extension that detects overly complex…

permissive · top 15,000 on PyPI

flake8-pie

A flake8 plugin that detects code quality…

permissive · top 15,000 on PyPI