- Direct instantiation like
UserUUID()no longer generates new UUIDs- Use
UserUUID.factory()for random generation - Use
UserUUID(factory_uuid)to wrap existing UUID instances - Version-specific factory methods accept their required parameters:
- PUUIDv1/v6: node, clock_seq
- PUUIDv3/v5: namespace, name
- PUUIDv8: a, b, c
- PUUIDv4/v7: no parameters
- Use
- The specialization syntax (
UserUUID = PUUIDv4[Literal["user"]]) is no longer supported. Instead writeclass UserUUID(PUUIDv4[Literal["user"]]): .... The rationale behind this change.
- PUUID is now compatible for use in FastAPI using Pydantic models.
isinstancechecks andcaseclauses are correctly understood by major type checkers.
- SQLAlchemy integration: Make sure to remove the
prefix_lengthargument at class instantiation.
- Remove prefix_length: The prefix length is automatically derived from the PUUID class for the SQLAlchemy integration.
- Empty prefix strings are now disallowed: Attempting specialization with an empty string literal e.g.
class UserUUID(PUUIDv4[Literal[""]]):now raises aPUUIDError - Prefer the new specialization syntax; the old
_prefixpattern is discouraged.- Recommended (v1.1.0+):
UserUUID = PUUIDv4[Literal["user"]] - Discouraged (v1.0.0 style):
class UserUUID(PUUIDv4[Literal["user"]]): _prefix = "user" - The old pattern is still supported for backwards compatibility, but it can silently drift (e.g.
_prefixnot matching theLiteral[...]), usingclass UserUUID(PUUIDv4[Literal["user"]])is fine, but the_prefixis no longer necessary
- Recommended (v1.1.0+):
- Pydantic is now optional. If you rely on pydantic integration, install pUUID with:
pip install 'pUUID[pydantic]'
- Base class rename:
PUUIDwas renamed toPUUIDBase.- For backwards compatibility,
puuid.PUUIDis still available as an alias ofPUUIDBase.
- For backwards compatibility,
- Dynamic Type Specialization: Support for creating prefixed UUID classes directly via subscripting, e.g.,
UserUUID = PUUIDv4[Literal["user"]]. - Backward Compatibility Layer: Added an alias for
PUUIDBaseasPUUIDto maintain compatibility with v1.0.0 inheritance patterns.
- Renamed Base Class:
PUUIDis nowPUUIDBaseto better reflect its role as a generic abstract base. - SQLAlchemy Improvements:
SqlPUUIDis now generic, allowing better type-hinting of mapped columns.
- Initial release.