Skip to content

Commit

Permalink
💚 Fix CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
mom1 committed Dec 15, 2024
1 parent aaee750 commit 9f49c27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
18 changes: 11 additions & 7 deletions apiclient_pydantic/serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import inspect
from collections.abc import Awaitable
from functools import partial
from typing import Annotated, Any, Callable, Optional, TypeVar, Union, cast
from typing import TYPE_CHECKING, Annotated, Any, Callable, TypeVar, cast

from apiclient import APIClient
from pydantic import AfterValidator, BaseModel, ConfigDict
Expand All @@ -16,6 +17,9 @@
from pydantic.plugin._schema_validator import create_schema_validator
from pydantic.validate_call_decorator import _check_function_type

if TYPE_CHECKING:
from collections.abc import Awaitable

T = TypeVar('T', bound=APIClient)
AnyCallableT = TypeVar('AnyCallableT', bound=Callable[..., Any])
TModel = TypeVar('TModel', bound=BaseModel)
Expand Down Expand Up @@ -72,12 +76,12 @@ async def return_val_wrapper(aw: Awaitable[Any]) -> None:


def serialize(
__func: Optional[AnyCallableT] = None,
__func: AnyCallableT | None = None,
/,
*,
config: Optional[ConfigDict] = None,
config: ConfigDict | None = None,
validate_return: bool = True,
response: Optional[type[BaseModel]] = None,
response: type[BaseModel] | None = None,
) -> AnyCallableT | Callable[[AnyCallableT], AnyCallableT]:
parent_namespace = _typing_extra.parent_frame_namespace()

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


def serialize_all_methods(
__cls: Optional[type[T]] = None, /, *, config: Optional[ConfigDict] = None
) -> Union[AnyCallableT, Callable[[AnyCallableT], AnyCallableT], Callable[[type[T]], type[T]]]:
__cls: type[T] | None = None, /, *, config: ConfigDict | None = None
) -> AnyCallableT | Callable[[AnyCallableT], AnyCallableT] | Callable[[type[T]], type[T]]:
def decorate(cls: type[T]) -> type[T]:
for attr, value in vars(cls).items():
if not attr.startswith('_') and inspect.isfunction(value) and attr not in APICLIENT_METHODS:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ fail_under = 100
show_missing = true
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
Expand Down

0 comments on commit 9f49c27

Please sign in to comment.