mirror of
https://github.com/exo-explore/exo.git
synced 2025-12-23 22:27:50 -05:00
Remove Bad UUID Implementation
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
import uuid
|
||||
from typing import Callable, TypeVar
|
||||
|
||||
from pydantic import UUID4, BaseModel
|
||||
|
||||
NT = TypeVar("NT", bound=str)
|
||||
type NewTypeGenerator[NT] = Callable[[str], NT]
|
||||
|
||||
|
||||
class _UuidValidator(BaseModel):
|
||||
id: UUID4
|
||||
|
||||
|
||||
def _generate_uuid() -> str:
|
||||
"""Return a freshly generated RFC-4122 UUID version 4 in canonical string form."""
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
def generate_uuid(type_wrapper: NewTypeGenerator[NT]) -> NT:
|
||||
return type_wrapper(_generate_uuid())
|
||||
|
||||
|
||||
def validate_uuid(data: str, type_wrapper: NewTypeGenerator[NT]) -> NT:
|
||||
validated_model = _UuidValidator.model_validate({"id": data})
|
||||
return type_wrapper(str(validated_model.id))
|
||||
Reference in New Issue
Block a user