{"id":6633,"library":"flake8-class-attributes-order","title":"Flake8 Class Attributes Order","description":"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.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/best-doctor/flake8-class-attributes-order","tags":["flake8","linter","code quality","style guide","class attributes","static analysis"],"install":[{"cmd":"pip install flake8-class-attributes-order","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a plugin for Flake8, so Flake8 itself is required to run the checks.","package":"flake8"},{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"note":"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.","symbol":"plugin","correct":"Install 'flake8-class-attributes-order'; it's automatically discovered by Flake8."}],"quickstart":{"code":"import os\n\n# Create a dummy python file for flake8 to check\nwith open('my_module.py', 'w') as f:\n    f.write(\"\"\"class MyClass:\n    FOO = 1\n    def __init__(self):\n        self.bar = 2\n    def method_a(self):\n        pass\n\"\"\")\n\n# Create a flake8 configuration file to enable strict mode (optional, but good for demo)\nwith open('setup.cfg', 'w') as f:\n    f.write(\"[flake8]\\nuse_class_attributes_order_strict_mode = True\\n\")\n\n# Run flake8. Note: flake8's exit code is non-zero if errors are found.\n# We use os.system for demonstration; in a real CI, you'd just run 'flake8'.\nprint(\"Running flake8 without strict mode (default order):\")\nos.system(\"flake8 my_module.py\")\n\nprint(\"\\nRunning flake8 with strict mode (via setup.cfg):\")\nos.system(\"flake8 my_module.py\")\n\n# Clean up\nos.remove('my_module.py')\nos.remove('setup.cfg')","lang":"python","description":"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`."},"warnings":[{"fix":"Upgrade to Python 3.9 or a later compatible version.","message":"Version 0.3.0 dropped support for Python 3.8. Ensure your environment uses Python 3.9 or newer.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Upgrade to Python 3.8 or a later compatible version.","message":"Version 0.2.0 dropped support for Python 3.7. Ensure your environment uses Python 3.8 or newer to use this version.","severity":"breaking","affected_versions":">=0.2.0, <0.3.0"},{"fix":"Add `[flake8]\\nuse_class_attributes_order_strict_mode = True` to your project's `setup.cfg` or `.flake8` file.","message":"To enable stricter attribute ordering checks, set `use_class_attributes_order_strict_mode = True` in your `flake8` configuration file (e.g., `setup.cfg`, `tox.ini`, or `.flake8`).","severity":"gotcha","affected_versions":"All"},{"fix":"Add `ignore = CCE001,CCE002` (or specific codes) under the `[flake8]` section of your configuration file.","message":"The plugin introduces specific error codes, such as CCE001 ('Wrong class attributes order') and CCE002 ('Class has class level logic'). If you wish to ignore these, you must explicitly add them to the `ignore` list in your Flake8 configuration.","severity":"gotcha","affected_versions":"All"},{"fix":"Refer to the documentation for the default order and define `class_attributes_order` in your `[flake8]` config section to match your desired sequence.","message":"Custom attribute orders can be defined using the `class_attributes_order` setting in the Flake8 configuration file. The default order is specific, and deviations will be reported.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}