Change MusicBand class to StrEnum (issue #73) (#80)

Changed to StrEnum, which avoids the need for multiple inheritance (str, Enum) and makes the intent clearer
This commit is contained in:
nathanielce24
2026-01-10 02:43:48 -06:00
committed by GitHub
parent ec94e9393b
commit 3f96300886

View File

@@ -197,11 +197,11 @@ Pydantic has a rich set of features to validate and transform data.
In addition to standard features like required and optional fields with default values,
Pydantic has built-in data processing tools like regex validation, enums, string manipulation, email validation, and more.
```python
from enum import Enum
from enum import StrEnum
from pydantic import AnyUrl, BaseModel, EmailStr, Field
class MusicBand(str, Enum):
class MusicBand(StrEnum):
AEROSMITH = "AEROSMITH"
QUEEN = "QUEEN"
ACDC = "AC/DC"