{ "info": { "author": "Christopher Cordero", "author_email": "ccordero@protonmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Pylint-Enums\n\n## Installation:\n\n```\n$ pip install pylint_enums # a conventional option\n$ pipenv install pylint_enums # a more modern option\n```\n\n## Usage:\n- Follow instructions to add `pylint_enums` as part of your loaded plugins.\n - Option 1 (.pylintrc)\n - Add `load-plugins=pylint_enums` to your `.pylintrc`.\n - Use pylint normally, i.e., `$ pylint [filepath]`\n - Option 2 (command line option)\n - `$ pylint [filepath] --load-plugins=pylint_enums`\n\n## What this is:\n\nThis is a tiny pylint plugin that adds a checker for Enum subclasses. It warns you when you haven't provided a typed annotation for the `value` attribute and when a `__str__` method has not been defined for the Enum when the type annotation isn't part of a finite list of simple types.\n\n`__str__` declaration is not enforced for the following types:\n* `str`\n* `int`\n* `decimal`\n* `float`\n\n## Why this is helpful:\n\nTypically, the value of an enum doesn't matter.\n\n```\nfrom enum import Enum\n\nclass Foo(Enum):\n FIRST = 'these'\n SECOND = 'usually'\n THIRD = 'don\\'t'\n FOURTH = 'matter'\n```\n\nHowever, in certain applications and/or use-cases, you actually do care about the value of each enum member. Specifically, you may use them as a `verbose_name` or a `pretty_name` for displaying to the user, or you may want to assign it a stateful value and use its contents later.\n\n```\nfrom enum import Enum\nfrom typing import NamedTuple\n\nclass FooMember(NamedTuple):\n label: str\n rank: int\n\nclass Foo(Enum):\n FIRST = FooMember(label='first', rank=1)\n SECOND = FooMember(label='second', rank=2)\n THIRD = FooMember(label='third', rank=3)\n FOURTH = FooMember(label='fourth', rank=4)\n\n def __str__(self) -> str:\n return self.value.label\n```\n\nAs of this writing, `mypy==0.600` is unable to infer the types of the member values. They resolve to `'Any'`:\n\n```\nreveal_type(Foo) # 'def (value: Any) -> foo.Foo'\nreveal_type(Foo.FIRST) # 'foo.Foo'\nreveal_type(Foo.FIRST.value) # 'Any'\n```\n\nThis can be problematic for `mypy` users that rely on type hints to maintain their code base. When you write a function that returns `Foo.FIRST.value`, our tooling is unable to help us figure out whether this value is a `str`, a `NamedTuple`, or some other value. Ideally, we would add additional type hints to the Enum:\n\n```\nclass Foo(Enum):\n value: FooMember\n FIRST = FooMember(label='first', rank=1)\n ...\n```\n\nBut alas, this requires developer vigilance to remember to do. If you're maintaining many enums across multiple files, it could be annoying to make sure that they and all future defined Enums are adequately typed.\n\nThis pylint plugin will raise errors when `value` is not typed and when the value is typed to something complex and the Enum is missing a `__str__` method.\n\n## Author\n\n[Christopher Sabater Cordero](https://github.com/cs-cordero)\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/cs-cordero/pylint_enums", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pylint-enums", "package_url": "https://pypi.org/project/pylint-enums/", "platform": "", "project_url": "https://pypi.org/project/pylint-enums/", "project_urls": { "Homepage": "https://github.com/cs-cordero/pylint_enums" }, "release_url": "https://pypi.org/project/pylint-enums/0.0.5/", "requires_dist": [ "pylint" ], "requires_python": "", "summary": "A Pylint plugin that checks for a specific implementation of Enum subclasses.", "version": "0.0.5" }, "last_serial": 3971885, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "0e70b1128795e98cd693be5c65540582", "sha256": "bfc574bc2c5a006d566f3f2abac75e71242b12c4f39ed8da9a9cc74ded8e66bf" }, "downloads": -1, "filename": "pylint_enums-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "0e70b1128795e98cd693be5c65540582", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5073, "upload_time": "2018-06-10T15:44:18", "url": "https://files.pythonhosted.org/packages/a9/e5/1559b9419053161f8ca07b3b0f9d64c1e715d42869472ca93a981754932c/pylint_enums-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c214ba211751c10218efbc4f31b7401a", "sha256": "be8ec2caae87b05697e006d5ee324a200ebff1e82d58b68614c677135c828ee1" }, "downloads": -1, "filename": "pylint_enums-0.0.2.tar.gz", "has_sig": false, "md5_digest": "c214ba211751c10218efbc4f31b7401a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4124, "upload_time": "2018-06-10T15:44:20", "url": "https://files.pythonhosted.org/packages/8b/51/dd2e73d58305833ce83bfba738278b4043659d283db638871c5b11792c58/pylint_enums-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "f468a4c667da79beb16f4138a9c5bfe3", "sha256": "8e06391428fc4a17cdb6a81a2e1ac538ee032ea20c4d7ddf36cded8e57568439" }, "downloads": -1, "filename": "pylint_enums-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "f468a4c667da79beb16f4138a9c5bfe3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5216, "upload_time": "2018-06-12T18:25:37", "url": "https://files.pythonhosted.org/packages/70/39/d5757847d1019fda8b9b6cba08f02eb60e56c351231f5b9917d1a4b98826/pylint_enums-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b5de5f2803143afb0679be4779804549", "sha256": "e30c3f86280cc9ca032845fb74ccd206c3ce2a8c6b303beec8b350291b846006" }, "downloads": -1, "filename": "pylint_enums-0.0.3.tar.gz", "has_sig": false, "md5_digest": "b5de5f2803143afb0679be4779804549", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4283, "upload_time": "2018-06-12T18:25:38", "url": "https://files.pythonhosted.org/packages/6c/8e/17a4e2b399f36e077db9eea0d34027bae28af24c25f30fe772e5d79ec31c/pylint_enums-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "84badb46f3804b1627a0fa7a5485a6c9", "sha256": "5cb93f396ae8ac119dd9b54fcda47f4cb5397c035b1c6b45bf9bdcb2523e59b5" }, "downloads": -1, "filename": "pylint_enums-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "84badb46f3804b1627a0fa7a5485a6c9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5539, "upload_time": "2018-06-12T19:08:43", "url": "https://files.pythonhosted.org/packages/3b/92/03a697cadce1ed00ba6a0df25b151811018075fad9031f2bbb881c1b9445/pylint_enums-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ddd6586f91349d5cc669d3a110918c37", "sha256": "afa782b83625333e95f7c198557604bb10a9360f3fcc0effa1d2bf98d101326e" }, "downloads": -1, "filename": "pylint_enums-0.0.4.tar.gz", "has_sig": false, "md5_digest": "ddd6586f91349d5cc669d3a110918c37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4544, "upload_time": "2018-06-12T19:08:44", "url": "https://files.pythonhosted.org/packages/76/f1/831587e6d13301ff279c385e057e72f7c0c375ddcf4657ed4457c1a3bceb/pylint_enums-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "2224aa216f9124a27ba1a384348c81e2", "sha256": "8515f438f1ea1778b37bd6293e2528b4d1f49dfcab97201d6317e3134b65c493" }, "downloads": -1, "filename": "pylint_enums-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "2224aa216f9124a27ba1a384348c81e2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5852, "upload_time": "2018-06-17T21:10:09", "url": "https://files.pythonhosted.org/packages/43/9a/575529b6c1554f9e019a61d618470ee95223993e248cc34ec9e34a8cce31/pylint_enums-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38131fda5c0af1dd476390853c178957", "sha256": "20a98d810629dd02663088d10821db45490ee83f26e3ebdfc5f4e90a06b44738" }, "downloads": -1, "filename": "pylint_enums-0.0.5.tar.gz", "has_sig": false, "md5_digest": "38131fda5c0af1dd476390853c178957", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4823, "upload_time": "2018-06-17T21:10:10", "url": "https://files.pythonhosted.org/packages/d0/98/0cefde3c334f7000b1b9faec113db958e8368da82043d7818a2d4d86df14/pylint_enums-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2224aa216f9124a27ba1a384348c81e2", "sha256": "8515f438f1ea1778b37bd6293e2528b4d1f49dfcab97201d6317e3134b65c493" }, "downloads": -1, "filename": "pylint_enums-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "2224aa216f9124a27ba1a384348c81e2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5852, "upload_time": "2018-06-17T21:10:09", "url": "https://files.pythonhosted.org/packages/43/9a/575529b6c1554f9e019a61d618470ee95223993e248cc34ec9e34a8cce31/pylint_enums-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38131fda5c0af1dd476390853c178957", "sha256": "20a98d810629dd02663088d10821db45490ee83f26e3ebdfc5f4e90a06b44738" }, "downloads": -1, "filename": "pylint_enums-0.0.5.tar.gz", "has_sig": false, "md5_digest": "38131fda5c0af1dd476390853c178957", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4823, "upload_time": "2018-06-17T21:10:10", "url": "https://files.pythonhosted.org/packages/d0/98/0cefde3c334f7000b1b9faec113db958e8368da82043d7818a2d4d86df14/pylint_enums-0.0.5.tar.gz" } ] }