from __future__ import annotations

from typing import Iterable, List, Optional, Protocol, TypeVar

T = TypeVar("T")


class Repository(Protocol[T]):  # ← نه Protocol, Generic[T]
    def get(self, id) -> Optional[T]: ...
    def add(self, obj: T) -> None: ...
    def remove(self, obj: T) -> None: ...
    def list(self, *, limit: int | None = None, offset: int = 0) -> Iterable[T]: ...


class AsyncRepository(Protocol[T]):
    async def get(self, id) -> Optional[T]: ...
    def add(self, obj: T) -> None: ...
    async def remove(self, obj: T) -> None: ...
    async def list(self, *, limit: int | None = None, offset: int = 0) -> List[T]: ...
