{ "info": { "author": "Ilya Lebedev", "author_email": "melevir@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Framework :: Flake8", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Topic :: Software Development :: Documentation", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance" ], "description": "# flake8-class-attributes-order\n\n[![Build Status](https://github.com/best-doctor/flake8-class-attributes-order/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/best-doctor/flake8-class-attributes-order/actions/workflows/build.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/28b7cd9d0714ec4b93a3/maintainability)](https://codeclimate.com/github/best-doctor/flake8-class-attributes-order/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/28b7cd9d0714ec4b93a3/test_coverage)](https://codeclimate.com/github/best-doctor/flake8-class-attributes-order/test_coverage)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flake8-class-attributes-order)\n\nAn extension for flake8 to report on wrong class attributes order and\nclass level logic.\n\nThe validator can extract class attribute type: docstring, property,\nnested class, `GLOBAL_VAR`, etc.\nIf django model fields are detected, the validator can detect,\nif the field is link to another table (foreign key, generic key, etc)\nor not.\n\nAfter resolving each attribute type, validator checks attributes order.\n\nDefault configuration checks for the following order of attributes:\n\n- `__new__`\n- `__init__`\n- `__post_init__`\n- other magic methods\n- `@property`\n- `@staticmethod`\n- `@classmethod`\n- other methods\n- private methods\n\nIf the order is broken, validator will report on it.\n\nBesides methods, the validator checks other attributes methods:\ndocstrings, nested classes, constants, attributes, and so on.\n\nAlso validator checks, if class has no class level logic and report\nif any. Here is an example:\n\n```python\nclass PhoneForm(forms.Form):\n phone = forms.CharField(17, label='\u0422\u0435\u043b\u0435\u0444\u043e\u043d'.upper())\n\n # this should happen in __init__!\n phone.widget.attrs.update({'class': 'form-control phone'})\n\n```\n\n## Installation\n\n```terminal\npip install flake8-class-attributes-order\n```\n\n## Configuration\n\n### Strict mode\n\nThere is another preconfigured order that is more strict on private subtypes:\n\n- `__new__`\n- `__init__`\n- `__post_init__`\n- other magic method\n- `@property`\n- `@staticmethod`\n- `@classmethod`\n- other methods\n- private `@property`\n- private `@staticmethod`\n- private `@classmethod`\n- other private methods\n\nTo enable strict validation, please set the flag in your config file:\n\n```ini\n[flake8]\nuse_class_attributes_order_strict_mode = True\n```\n\n### Manual order configuration\n\nOrder can be manually configured via `class_attributes_order` config setting.\n\nFor example, if you prefer to put `class Meta` after constants and fields:\n\n```ini\n[flake8]\nclass_attributes_order =\n field,\n meta_class,\n nested_class,\n magic_method,\n property_method,\n static_method,\n class_method,\n method,\n private_method\n```\n\nConfigurable options:\n\n| Option | Description | Fallbacks to\\* |\n|:---------------------:|:-----------------------------------:|:--------------:|\n|meta_class |class Meta: (e.g. in Django projects)| nested_class |\n|nested_class |Other nested classes | None\\* |\n|constant |SOME_CONSTANTS | field |\n|outer_field |some = models.ForeignKey etc. | field |\n|field |Other fields | None |\n|`__new__` |`__new__` | magic_method |\n|`__init__` |`__init__` | magic_method |\n|`__post_init__` |`__post_init__` | magic_method |\n|`__str__` |`__str__` | magic_method |\n|magic_method |Other magic methods | method |\n|save |def save(...) | method |\n|delete |def delete(...) | method |\n|property_method |@property/@cached_property etc. | method |\n|private_property_method|@property/@cached_property with _ | property_method|\n|static_method |@staticmethod | method |\n|private_static_method |@staticmethod beginning with _ | static_method |\n|class_method |@classmethod | method |\n|private_class_method |@classmethod beginning with _ | class_method |\n|private_method |other methods beginning with _ | method |\n|method |other methods | None |\n\n\\* if not provided, will use its supertype order\n\n\\*\\* if not defined, such base types and all their subtypes (unless defined)\nwill be ignored during validation. It's recommended\nto set at least `nested_class`, `field` and `method`\n\nYou choose how detailed your configuration is.\nFor example, you can define order of each supported magic method\n(`__new__`, `__str__`, etc.), or set `magic_method`\nto allow any order among them or even just use `method`\n\n## Example\n\n```python\nDEBUG = True\n\n\nclass User:\n def fetch_info_from_crm(self):\n pass\n\n LOGIN_FIELD = 'email' # wtf? this should be on top of class definition!\n\n\nclass UserNode:\n class Meta:\n model = User\n\n if DEBUG: # not great idea at all\n def is_synced_with_crm(self):\n pass\n\n```\n\nUsage:\n\n```terminal\n$ flake8 test.py\ntest.py:5:5: CCE001 User.fetch_info_from_crm should be after User.LOGIN_FIELD\ntest.py:15:5: CCE002 Class level expression detected model UserNode, line 15\n```\n\nTested on Python 3.7.x and flake8 3.7.5.\n\n## Error codes\n\n| Error code | Description |\n|:----------:|:--------------------------------------------------------:|\n| CCE001 | Wrong class attributes order (`XXX should be after YYY`) |\n| CCE002 | Class level expression detected |\n\n## Contributing\n\nWe would love you to contribute to our project. It's simple:\n\n- Create an issue with bug you found or proposal you have.\n Wait for approve from maintainer.\n- Create a pull request. Make sure all checks are green.\n- Fix review comments if any.\n- Be awesome.\n\nHere are useful tips:\n\n- You can run all checks and tests with `make check`. Please do it\n before TravisCI does.\n- We use\n [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/en/python_styleguide.md).\n- We respect [Django CoC](https://www.djangoproject.com/conduct/).\n Make soft, not bullshit.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/best-doctor/flake8-class-attributes-order", "keywords": "flake8", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "flake8-class-attributes-order", "package_url": "https://pypi.org/project/flake8-class-attributes-order/", "platform": "", "project_url": "https://pypi.org/project/flake8-class-attributes-order/", "project_urls": { "Homepage": "https://github.com/best-doctor/flake8-class-attributes-order" }, "release_url": "https://pypi.org/project/flake8-class-attributes-order/0.1.3/", "requires_dist": [ "flake8", "typing-extensions" ], "requires_python": ">=3.7", "summary": "A flake8 extension that checks classes attributes order", "version": "0.1.3", "yanked": false, "yanked_reason": null }, "last_serial": 12997639, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d6852406204a36b0e9cfd3323eab42e4", "sha256": "b0d3c21f3a62cdb90a441660610ddcc65f5655ea837066f6a72def1f78bd9915" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d6852406204a36b0e9cfd3323eab42e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4940, "upload_time": "2019-02-15T10:42:29", "upload_time_iso_8601": "2019-02-15T10:42:29.025333Z", "url": "https://files.pythonhosted.org/packages/81/41/b74f37c66874bde53b3b64553c0e18450303d2218cc4658f5b8046ad6efd/flake8_class_attributes_order-0.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "cf955f3029cac88c0a8cf7ffeb7e246c", "sha256": "b88f88463036976ffc23c5a6dd392391635eaf6416e400611eda8c3429cd02aa" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.2.tar.gz", "has_sig": false, "md5_digest": "cf955f3029cac88c0a8cf7ffeb7e246c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4939, "upload_time": "2019-02-18T06:44:57", "upload_time_iso_8601": "2019-02-18T06:44:57.921154Z", "url": "https://files.pythonhosted.org/packages/5e/bc/d7d58661d4ec8971d851dd8d5fde4830863193d9741de9f180ea2f0aef39/flake8_class_attributes_order-0.0.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "ca3afc3167ad5ce06e7aad39305e1217", "sha256": "71a1ab446ccd197cb6a6febd0a59a658dd4918ca01d93afe8f6aa2a450e9e74b" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.3.tar.gz", "has_sig": false, "md5_digest": "ca3afc3167ad5ce06e7aad39305e1217", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4932, "upload_time": "2019-05-04T08:10:33", "upload_time_iso_8601": "2019-05-04T08:10:33.375520Z", "url": "https://files.pythonhosted.org/packages/43/17/9929b1b7a5937a226b33cac8b467f2c814fe81d0148f9d8058b5cbfea6b1/flake8_class_attributes_order-0.0.3.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "68448ee3f5c144e696692262cf6fc8e4", "sha256": "c2c6e4591a6800085634a88daa5df3be11a94e98acbee103e4b22e3d845b122d" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.4.tar.gz", "has_sig": false, "md5_digest": "68448ee3f5c144e696692262cf6fc8e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4983, "upload_time": "2019-09-05T05:50:47", "upload_time_iso_8601": "2019-09-05T05:50:47.841629Z", "url": "https://files.pythonhosted.org/packages/1d/56/8d76fdfb8f9fc6218623562153179651fcdea73782aa04c04a1cb19735e1/flake8_class_attributes_order-0.0.4.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "dd09876b6f1b462adfcea2890a3213da", "sha256": "4d6b2c2e6afeb5f90f3284df09a064da0f9156dabbba63d5fc8c89588db9d175" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.5.tar.gz", "has_sig": false, "md5_digest": "dd09876b6f1b462adfcea2890a3213da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4990, "upload_time": "2019-09-05T06:06:42", "upload_time_iso_8601": "2019-09-05T06:06:42.355757Z", "url": "https://files.pythonhosted.org/packages/0f/e0/16372c784f5ababe10a562ae7d317e54d080c93aa8f401061d3aa2b8a8bb/flake8_class_attributes_order-0.0.5.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "69765398c68b7fa9f1646688ad4a5cef", "sha256": "e79215345e3b3feeee39318c740da7f4512d4456c03241470428f8bfb8a50acb" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.6.tar.gz", "has_sig": false, "md5_digest": "69765398c68b7fa9f1646688ad4a5cef", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 5421, "upload_time": "2019-10-26T03:02:24", "upload_time_iso_8601": "2019-10-26T03:02:24.998366Z", "url": "https://files.pythonhosted.org/packages/53/46/e3cbec716bb5877aaf71c2bcb1d0ee40a078cbd2739934a75fa013fee15d/flake8_class_attributes_order-0.0.6.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "fab427c3773939ee93ca2cfce97da550", "sha256": "49768054bbee1fc89d0e27851338c167705a7afc7006093a4924567337c0f920" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.0.7.tar.gz", "has_sig": false, "md5_digest": "fab427c3773939ee93ca2cfce97da550", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5625, "upload_time": "2019-11-04T04:38:53", "upload_time_iso_8601": "2019-11-04T04:38:53.690801Z", "url": "https://files.pythonhosted.org/packages/20/95/1faf315279d2150d0203da485d971831239a3e8605ce2b9fba534ec52ea4/flake8_class_attributes_order-0.0.7.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "6f65486454b987d2facacbbb5082091a", "sha256": "ad5c85b09edcb593ae244d8839660d38e777c6ccb701e9e3edc80730a58f2228" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.0.tar.gz", "has_sig": false, "md5_digest": "6f65486454b987d2facacbbb5082091a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7249, "upload_time": "2020-03-15T15:34:23", "upload_time_iso_8601": "2020-03-15T15:34:23.621679Z", "url": "https://files.pythonhosted.org/packages/23/e9/75a23bfc2d67d7ef2999e7b63d75c15977f73504fe62ad162bd575011423/flake8_class_attributes_order-0.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "cc8cad87faf26ed8a6dd4b6029695487", "sha256": "6e0fe254b8d3fa649c50eb971b6b207635f75effbc0e0c04d19dbfa5d0f2897b" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.1.tar.gz", "has_sig": false, "md5_digest": "cc8cad87faf26ed8a6dd4b6029695487", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8378, "upload_time": "2020-05-18T14:49:02", "upload_time_iso_8601": "2020-05-18T14:49:02.673486Z", "url": "https://files.pythonhosted.org/packages/11/78/4fa78abe1f9043bf3a61fbe57acb73425def20bf7c80b484ee2046c5c0e5/flake8_class_attributes_order-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "dfff93ab582b99ed20c55563f7fb1a4e", "sha256": "48c68828590078eba062782c611f9540fd7c0fb8450dc4576b9cb6e826d9fdcf" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.2.tar.gz", "has_sig": false, "md5_digest": "dfff93ab582b99ed20c55563f7fb1a4e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 10061, "upload_time": "2021-01-14T15:04:23", "upload_time_iso_8601": "2021-01-14T15:04:23.974609Z", "url": "https://files.pythonhosted.org/packages/6b/17/fcea0724565ec251ab16b8b1067e809c452df2318748f1e365686737f9e6/flake8_class_attributes_order-0.1.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "95e3d010ca3ded23582c3e69643054a9", "sha256": "6398368da4511cdda1a7c0e25934bcaac49d9df89aa2842729353b4a20f7ed13" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "95e3d010ca3ded23582c3e69643054a9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 9393, "upload_time": "2022-02-24T15:47:08", "upload_time_iso_8601": "2022-02-24T15:47:08.076899Z", "url": "https://files.pythonhosted.org/packages/0e/05/7cecfad1708692d618eea8570804b86ec89a9e8570898b5a2637851bdf02/flake8_class_attributes_order-0.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "1474bdbfaa3058d7c977d7e91a78aaa8", "sha256": "9dde5581832d278ce247d4c47777f980cd86df2232bc0c50275144857d56e91d" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.3.tar.gz", "has_sig": false, "md5_digest": "1474bdbfaa3058d7c977d7e91a78aaa8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 10271, "upload_time": "2022-02-24T15:47:09", "upload_time_iso_8601": "2022-02-24T15:47:09.848430Z", "url": "https://files.pythonhosted.org/packages/48/86/4d6eb75d7108ea84a72d5100da5bdb23165938cc0daae83e291f5fc51dd3/flake8_class_attributes_order-0.1.3.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "95e3d010ca3ded23582c3e69643054a9", "sha256": "6398368da4511cdda1a7c0e25934bcaac49d9df89aa2842729353b4a20f7ed13" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "95e3d010ca3ded23582c3e69643054a9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7", "size": 9393, "upload_time": "2022-02-24T15:47:08", "upload_time_iso_8601": "2022-02-24T15:47:08.076899Z", "url": "https://files.pythonhosted.org/packages/0e/05/7cecfad1708692d618eea8570804b86ec89a9e8570898b5a2637851bdf02/flake8_class_attributes_order-0.1.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "1474bdbfaa3058d7c977d7e91a78aaa8", "sha256": "9dde5581832d278ce247d4c47777f980cd86df2232bc0c50275144857d56e91d" }, "downloads": -1, "filename": "flake8_class_attributes_order-0.1.3.tar.gz", "has_sig": false, "md5_digest": "1474bdbfaa3058d7c977d7e91a78aaa8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7", "size": 10271, "upload_time": "2022-02-24T15:47:09", "upload_time_iso_8601": "2022-02-24T15:47:09.848430Z", "url": "https://files.pythonhosted.org/packages/48/86/4d6eb75d7108ea84a72d5100da5bdb23165938cc0daae83e291f5fc51dd3/flake8_class_attributes_order-0.1.3.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }