Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
uriyyo authored Sep 8, 2024
2 parents c3507ba + c6d520b commit 56bf025
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ] # , "3.12" ]
pydantic_v2: [ "true", "false" ]
fastapi_version: [ "<0.112.4", ">=0.112.4" ]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -66,6 +67,10 @@ jobs:
run: |
poetry run pip install -U --pre fastapi pydantic
- name: Install FastAPI
run : |
poetry run pip install -U "fastapi${{ matrix.fastapi_version }}"
- name: Unit tests pydantic v2
if: ${{ matrix.pydantic_v2 == 'true' }}
run: |
Expand Down
13 changes: 11 additions & 2 deletions fastapi_pagination/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from fastapi.routing import APIRoute, APIRouter
from pydantic import BaseModel
from starlette.routing import request_response
from typing_extensions import deprecated
from typing_extensions import deprecated, no_type_check

from .bases import AbstractPage, AbstractParams
from .default import Page
Expand Down Expand Up @@ -338,6 +338,15 @@ async def _page_ctx_dependency(
return _page_ctx_dependency


@no_type_check
def _bet_body_field(route: APIRoute) -> Optional[Any]:
try:
# starting from fastapi 0.113.0 get_body_field changed its signature
return get_body_field(flat_dependant=route.dependant, name=route.unique_id, embed_body_fields=True)
except TypeError:
return get_body_field(dependant=route.dependant, name=route.unique_id)


ParentT = TypeVar("ParentT", APIRouter, FastAPI)


Expand All @@ -361,7 +370,7 @@ def _update_route(route: APIRoute) -> None:
),
)

route.body_field = get_body_field(dependant=route.dependant, name=route.unique_id)
route.body_field = _bet_body_field(route)
route.app = request_response(route.get_route_handler())


Expand Down
70 changes: 35 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ pytest-cov = "^5.0.0"
pytest-asyncio = "^0.21.1"
flaky = "^3.8.1"
pre-commit = "^3.5.0"
Faker = "^28.0.0"
Faker = "^28.4.1"
psycopg2-binary = "^2.9.9"
mkdocs = "^1.5.3"
mkdocs-material = "^9.5.33"
mkdocs = "^1.6.1"
mkdocs-material = "^9.5.34"
pymdown-extensions = "^10.9"
fontawesome-markdown = "^0.2.6"
httpx = "^0.27.2"
Expand All @@ -62,7 +62,7 @@ requests = "^2.32.2"
uvicorn = "^0.30.6"
Jinja2 = "^3.1.4"
mypy = "^1.11.2"
ruff = "^0.6.2"
ruff = "^0.6.4"

[tool.poetry.extras]
sqlmodel = ["sqlmodel", "sqlakeyset"]
Expand Down

0 comments on commit 56bf025

Please sign in to comment.