Skip to content

Commit 9f49c27

Browse files
committed
💚 Fix CI.
1 parent aaee750 commit 9f49c27

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.8", "3.9", "3.10", "3.11"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1515
fail-fast: false
1616
steps:
1717
- uses: actions/checkout@v4

apiclient_pydantic/serializers.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from __future__ import annotations
2+
13
import inspect
2-
from collections.abc import Awaitable
34
from functools import partial
4-
from typing import Annotated, Any, Callable, Optional, TypeVar, Union, cast
5+
from typing import TYPE_CHECKING, Annotated, Any, Callable, TypeVar, cast
56

67
from apiclient import APIClient
78
from pydantic import AfterValidator, BaseModel, ConfigDict
@@ -16,6 +17,9 @@
1617
from pydantic.plugin._schema_validator import create_schema_validator
1718
from pydantic.validate_call_decorator import _check_function_type
1819

20+
if TYPE_CHECKING:
21+
from collections.abc import Awaitable
22+
1923
T = TypeVar('T', bound=APIClient)
2024
AnyCallableT = TypeVar('AnyCallableT', bound=Callable[..., Any])
2125
TModel = TypeVar('TModel', bound=BaseModel)
@@ -72,12 +76,12 @@ async def return_val_wrapper(aw: Awaitable[Any]) -> None:
7276

7377

7478
def serialize(
75-
__func: Optional[AnyCallableT] = None,
79+
__func: AnyCallableT | None = None,
7680
/,
7781
*,
78-
config: Optional[ConfigDict] = None,
82+
config: ConfigDict | None = None,
7983
validate_return: bool = True,
80-
response: Optional[type[BaseModel]] = None,
84+
response: type[BaseModel] | None = None,
8185
) -> AnyCallableT | Callable[[AnyCallableT], AnyCallableT]:
8286
parent_namespace = _typing_extra.parent_frame_namespace()
8387

@@ -98,8 +102,8 @@ def validate(function: AnyCallableT) -> AnyCallableT:
98102

99103

100104
def serialize_all_methods(
101-
__cls: Optional[type[T]] = None, /, *, config: Optional[ConfigDict] = None
102-
) -> Union[AnyCallableT, Callable[[AnyCallableT], AnyCallableT], Callable[[type[T]], type[T]]]:
105+
__cls: type[T] | None = None, /, *, config: ConfigDict | None = None
106+
) -> AnyCallableT | Callable[[AnyCallableT], AnyCallableT] | Callable[[type[T]], type[T]]:
103107
def decorate(cls: type[T]) -> type[T]:
104108
for attr, value in vars(cls).items():
105109
if not attr.startswith('_') and inspect.isfunction(value) and attr not in APICLIENT_METHODS:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ fail_under = 100
175175
show_missing = true
176176
exclude_lines = [
177177
"pragma: no cover",
178+
"if TYPE_CHECKING:",
178179
"raise AssertionError",
179180
"raise NotImplementedError",
180181
"if __name__ == .__main__.:",

0 commit comments

Comments
 (0)