{"id":17465173,"url":"https://github.com/dusktreader/auto-name-enum","last_synced_at":"2026-03-05T20:49:16.837Z","repository":{"id":39659820,"uuid":"317977130","full_name":"dusktreader/auto-name-enum","owner":"dusktreader","description":"String-based Enum class that automatically assigns values","archived":false,"fork":false,"pushed_at":"2022-05-28T18:55:42.000Z","size":42,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-18T05:11:16.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dusktreader.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-02T20:03:01.000Z","updated_at":"2023-08-06T22:18:08.000Z","dependencies_parsed_at":"2022-08-29T15:31:14.007Z","dependency_job_id":null,"html_url":"https://github.com/dusktreader/auto-name-enum","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusktreader%2Fauto-name-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusktreader%2Fauto-name-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusktreader%2Fauto-name-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dusktreader%2Fauto-name-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dusktreader","download_url":"https://codeload.github.com/dusktreader/auto-name-enum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239863164,"owners_count":19709556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T11:08:59.322Z","updated_at":"2026-03-05T20:49:16.830Z","avatar_url":"https://github.com/dusktreader.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A utility for producing enums with automatic names\n\nThis package provides an extension of python Enum objects that automatically\nassigns values to members. This uses the `auto()` feature to assign text values\nto the enums instead of having to manually set them.\n\n\n## Specifying your enum\nFor example, you might create an enum with this like so:\n\n```\nclass Aliens(AutoNameEnum):\n    JAWA = auto()\n    EWOK = auto()\n    HUTT = auto()\n    PYKE = auto()\n```\n\n## Getting values\n\nUsing the class, verify the value of `JAWA` would be 'JAWA':\n\n```\n\u003e\u003e\u003e print(Aliens.JAWA.value)\n'JAWA'\n```\n\nYou may also get the same value by just using the name of the item:\n\n```\n\u003e\u003e\u003e print(Aliens.JAWA)\n'JAWA'\n```\n\n## Iterating\n\nPython enums may be iterated over:\n\n```\nfor alien in Aliens:\n    print(f\"name: {alien.name}, value: {alien.value}\")\n```\n\nFor more information on enums (and the auto method), see [the official docs]\n(https://docs.python.org/3/library/enum.html)\n\n\n## Mixins\n\nThere are two mixins provided that change the behavior of `auto()`:\n\n- `LowerCaseMixin`: values produced by `auto()` are in all lower-case\n- `TitleCaseMixin`: values produced by `auto()` will be in title- case (lower-case except for first letter)\n\nWhen these mixins are used, they _must_ be included after `AutoNameEnum` in the class inheritance declaration:\n\n```python\nclass Aliens(AutoNameEnum, TitleCaseMixin)\n    JAWA = auto()\n    EWOK = auto()\n    HUTT = auto()\n    PYKE = auto()\n```\n\n\n## Documented members with `autodoc()`\n\nThe `autodoc()` function works like `auto()`, but also attaches a description to each enum member.\nThis is useful for self-documenting enums where members need human-readable explanations:\n\n```python\nclass Aliens(AutoNameEnum):\n    JAWA = autodoc(\"A small, rodent-like alien from Tatooine\")\n    EWOK = autodoc(\"A furry, diminutive alien from the forest moon of Endor\")\n    HUTT = autodoc(\"A large, slug-like alien from Nal Hutta\")\n    PYKE = autodoc(\"A secretive, spice-dealing alien from Oba Diah\")\n```\n\nThe value works just like `auto()`:\n\n```\n\u003e\u003e\u003e print(Aliens.JAWA.value)\n'JAWA'\n```\n\nAccess the description via the `.description` property:\n\n```\n\u003e\u003e\u003e print(Aliens.JAWA.description)\n'A small, rodent-like alien from Tatooine'\n```\n\nYou can mix `auto()` and `autodoc()` in the same enum. Members created with `auto()` will return\n`None` for `.description`:\n\n```python\nclass Aliens(AutoNameEnum):\n    JAWA = autodoc(\"A small, rodent-like alien from Tatooine\")\n    EWOK = auto()\n    HUTT = autodoc(\"A large, slug-like alien from Nal Hutta\")\n```\n\n```\n\u003e\u003e\u003e print(Aliens.JAWA.description)\n'A small, rodent-like alien from Tatooine'\n\u003e\u003e\u003e print(Aliens.EWOK.description)\nNone\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdusktreader%2Fauto-name-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdusktreader%2Fauto-name-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdusktreader%2Fauto-name-enum/lists"}