Loading poolpay/model/Base.py +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ class Base(Retrievable): uuid: Mapped[UUID] = mapped_column(Uuid(), primary_key=True, default=uuid4) @classmethod def get_only(cls, uuid: str | UUID) -> Base | None: def get_only[T](cls: type[T], uuid: str | UUID) -> T | None: if isinstance(uuid, str): try: # Manually convert the uuid to a UUID object (even though sqlalchemy-uuid would do that Loading poolpay/model/Retrievable.py +3 −3 Original line number Diff line number Diff line from __future__ import annotations from collections.abc import Sequence from typing import Any, Self from typing import Any from sqlalchemy import select from sqlalchemy.orm import DeclarativeBase, MappedColumn Loading Loading @@ -30,7 +30,7 @@ class Retrievable(DeclarativeBase): return None @classmethod def get_all(cls) -> Sequence[Self]: def get_all[T](cls: type[T]) -> Sequence[T]: """ Return all instances of this type. """ Loading @@ -44,7 +44,7 @@ class Retrievable(DeclarativeBase): ) @classmethod def get_only(cls, primary_key: Any) -> Self | None: def get_only[T](cls: type[T], primary_key: Any) -> T | None: """ Return the instance of this type with the given primary key or None if it doesn't exist. """ Loading Loading
poolpay/model/Base.py +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ class Base(Retrievable): uuid: Mapped[UUID] = mapped_column(Uuid(), primary_key=True, default=uuid4) @classmethod def get_only(cls, uuid: str | UUID) -> Base | None: def get_only[T](cls: type[T], uuid: str | UUID) -> T | None: if isinstance(uuid, str): try: # Manually convert the uuid to a UUID object (even though sqlalchemy-uuid would do that Loading
poolpay/model/Retrievable.py +3 −3 Original line number Diff line number Diff line from __future__ import annotations from collections.abc import Sequence from typing import Any, Self from typing import Any from sqlalchemy import select from sqlalchemy.orm import DeclarativeBase, MappedColumn Loading Loading @@ -30,7 +30,7 @@ class Retrievable(DeclarativeBase): return None @classmethod def get_all(cls) -> Sequence[Self]: def get_all[T](cls: type[T]) -> Sequence[T]: """ Return all instances of this type. """ Loading @@ -44,7 +44,7 @@ class Retrievable(DeclarativeBase): ) @classmethod def get_only(cls, primary_key: Any) -> Self | None: def get_only[T](cls: type[T], primary_key: Any) -> T | None: """ Return the instance of this type with the given primary key or None if it doesn't exist. """ Loading