Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ classifiers = [
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
]
dependencies = [
"typing-extensions; python_version < '3.11'",
]

[project.urls]
Homepage = "https://github.com/mdomke/python-ulid"
Expand Down
10 changes: 7 additions & 3 deletions ulid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
from typing import TYPE_CHECKING
from typing import TypeVar

from typing_extensions import Self

from ulid import base32
from ulid import constants


if TYPE_CHECKING: # pragma: no cover
import sys
from collections.abc import Callable

from pydantic import GetCoreSchemaHandler
from pydantic import ValidatorFunctionWrapHandler
from pydantic_core import CoreSchema

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

try:
from importlib.metadata import version
except ImportError: # pragma: no cover
Expand Down Expand Up @@ -199,7 +203,7 @@ def parse(cls, value: Any) -> Self:
a value when they're unsure what format/primitive type it will be given in.
"""
if isinstance(value, ULID):
return cast(Self, value)
return cast("Self", value)
if isinstance(value, uuid.UUID):
return cls.from_uuid(value)
if isinstance(value, str):
Expand Down
8 changes: 7 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading