backports.strenum
Base class for creating enumerated constants that are also subclasses of str
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 on this page — 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
backports-strenum on PyPI
pip
pip install backports-strenumuv
uv add backports-strenumpoetry
poetry add backports-strenumInstalling 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 the current Python release (>=3.8.6,<3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 979 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,402,027/month — #1,626 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: backports_strenum-1.3.1-py3-none-any.whl
Keywords: backports, enum, strenum
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
StrEnumStrEnum is a string-based enum class that…
permissive · top 1,000 on PyPI
enum34Provides enumeration support for older Python…
permissive · top 5,000 on PyPI
matrix-enumExtends Python's built-in Enum to support…
permissive · top 15,000 on PyPI
enum-toolsProvides utilities to enhance Python's enum…
copyleft · top 5,000 on PyPI
aenumaenum provides advanced enumeration types…
permissive · top 1,000 on PyPI
enum-compatConditionally installs enum34 on Python…
permissive · top 5,000 on PyPI
pysubtypesProvides enhanced subclasses for Python…
permissive · top 15,000 on PyPI
django-enumProvides a Django model field type that stores…
permissive · top 15,000 on PyPI
constantlyProvides symbolic constant support in Python,…
permissive · top 5,000 on PyPI
exitstatusProvides portable, type-safe POSIX exit status…
permissive · top 15,000 on PyPI