--- id: backports-strenum version: "1.3.1" license: MIT license_treatment: permissive maintenance: dormant --- # backports.strenum — Base class for creating enumerated constants that are also subclasses of str License: permissive · Maintenance: dormant · Downloads: 8.4M/mo ## What it is and what it does backports.strenum is a direct copy of Python 3.11's StrEnum class, ported to run on Python 3.8.6 through 3.10. It lets you create enumeration classes whose members are both enum constants and string values, so they can be used interchangeably with strings in most contexts. Members support string operations like upper() and lower(), and equality checks work naturally (e.g., Color.RED == "red" returns True). The package is designed as a conditional dependency: code should import from the standard library on Python 3.11+, and fall back to backports.strenum only on earlier versions. It has no runtime dependencies and installs cleanly. Maintenance is dormant but intentional—the package is a static backport unlikely to need updates unless Python's enum semantics shift significantly. Use it for: - Define string-based enums in libraries that must support Python 3.8–3.10 while using native StrEnum on 3.11+. - Replace hardcoded string constants with type-safe enum members that retain string compatibility. - Build configuration or status classes where members need to serialize as strings and be usable in string comparisons. - Migrate legacy code from plain string constants to enums without breaking string-based APIs. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides StrEnum, a string-based enumeration class from Python 3.11, for use on Python 3.8.6 through 3.10, allowing enum members to behave as both strings and enumeration constants. Yes, if you need StrEnum on Python 3.8–3.10 and can configure it as a conditional dependency (install only on <3.11). The package is minimal, has no external dependencies, carries no known vulnerabilities, and uses a permissive MIT license. Dormant maintenance is acceptable because it is a static backport of a standard library feature. Not worth installing on Python 3.11+, where the standard library StrEnum should be used directly. ## Install pip install backports-strenum uv add backports-strenum poetry add backports-strenum ## Installing backports.strenum Before you install: Low install friction with no runtime dependencies. Maintenance is dormant—last release was 2023-12-09 and the repository shows no recent activity—but the package is intentionally minimal and unlikely to require updates unless Python's enum behavior changes. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal restrictions, making it safe to include in any project type. Quickstart: pip install backports.strenum from backports.strenum import StrEnum class Color(StrEnum): RED = "red" BLUE = "blue" print(Color.RED == "red") # True Package only installs on Python >=3.8.6 and <3.11; on Python 3.11+ the standard library StrEnum should be used instead. Verify before relying: - Whether the package's behavior fully matches Python 3.11's StrEnum in all edge cases, particularly around container operations that change in Python 3.12. - Whether conditional dependency configuration is documented for common package managers. - Full compatibility with all string operations and edge cases described in Python 3.11 enum documentation. ## Package facts - License: MIT (permissive) - Python support: capped_below_current - Install friction: low - Maintenance: dormant - Downloads: 8.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags string enum backport, strenum python 3.8, enum string subclass, backport python 3.11 enum, conditional enum dependency, string enumeration class, backport, enum, conditional-dependency [View on SkillFed](https://skillfed.io/packages/backports-strenum) · [View on PyPI](https://pypi.org/project/backports-strenum/)