Skip to content

Commit 9de7092

Browse files
committed
fix generic annotations for python < 3.12
1 parent 6deb2ec commit 9de7092

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

pocketbase/models/file_upload.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from typing import Sequence, Union
1+
from __future__ import annotations
2+
3+
from collections.abc import Sequence
24

35
from httpx._types import FileTypes
46

5-
FileUploadTypes = Union[FileTypes, Sequence[FileTypes]]
7+
FileUploadTypes = FileTypes | Sequence[FileTypes]
68

79

810
class FileUpload:

pocketbase/models/utils/list_result.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass, field
4+
from typing import Generic, TypeVar
45

56
from pocketbase.models.utils.base_model import Model
67

8+
T = TypeVar("T", bound=Model)
9+
710

811
@dataclass
9-
class ListResult[T: Model]:
12+
class ListResult(Generic[T]):
1013
page: int = 1
1114
per_page: int = 0
1215
total_items: int = 0

pocketbase/services/log_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import datetime
44
from dataclasses import dataclass
5-
from typing import Any, Union
5+
from typing import Any
66
from urllib.parse import quote
77

88
from pocketbase.models.log_request import LogRequest
@@ -14,7 +14,7 @@
1414
@dataclass
1515
class HourlyStats:
1616
total: int
17-
date: Union[str, datetime.datetime]
17+
date: str | datetime.datetime
1818

1919

2020
class LogService(BaseService):

pocketbase/services/utils/crud_service.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
from __future__ import annotations
22

33
from abc import ABC, abstractmethod
4-
from typing import TYPE_CHECKING, Any
4+
from typing import Any, Generic, TypeVar
55
from urllib.parse import quote
66

77
from pocketbase.errors import ClientResponseError
88
from pocketbase.models.utils.base_model import Model
99
from pocketbase.models.utils.list_result import ListResult
1010
from pocketbase.services.utils.base_service import BaseService
1111

12-
if TYPE_CHECKING:
13-
pass
12+
T = TypeVar("T", bound=Model)
1413

1514

16-
class CrudService[T: Model](BaseService, ABC):
15+
class CrudService(Generic[T], BaseService, ABC):
1716
@abstractmethod
1817
def base_crud_path(self) -> str:
1918
"""Base path for the crud actions (without trailing slash, eg. '/admins')."""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pocketbase"
3-
version = "0.13.0"
3+
version = "0.13.1"
44
description = "PocketBase SDK for python."
55
authors = ["Vithor Jaeger <[email protected]>", "Max Amling <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)