Skip to content

Commit 6a0ec5e

Browse files
update from maint-6.1.x (#870)
1 parent accd079 commit 6a0ec5e

File tree

26 files changed

+111
-72
lines changed

26 files changed

+111
-72
lines changed

.github/workflows/cicd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
3636
run: |
3737
uv run pre-commit run --all-files
38+
uv run --with mypy --with types-attrs mypy -p stac_fastapi
3839
3940
- name: Run tests
4041
run: uv run pytest -svvv

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
- id: ruff-format
88

99
- repo: https://github.com/pre-commit/mirrors-mypy
10-
rev: v1.15.0
10+
rev: v1.19.0
1111
hooks:
1212
- id: mypy
1313
language_version: python

CHANGES.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
- support for python 3.9 and 3.10
88

9+
## [6.1.3] - 2025-12-09
10+
911
### Fixed
1012

11-
- fixed output type for `api.models.create_request_model` and `api.models.create_get_request_model` methods
13+
- fixed type hints
1214

1315
## [6.1.2] - 2025-12-09
1416

@@ -686,7 +688,8 @@ Full changelog: https://stac-utils.github.io/stac-fastapi/migrations/v3.0.0/#cha
686688

687689
* First PyPi release!
688690

689-
[Unreleased]: <https://github.com/stac-utils/stac-fastapi/compare/6.1.2..main>
691+
[Unreleased]: <https://github.com/stac-utils/stac-fastapi/compare/6.1.3..main>
692+
[6.1.3]: <https://github.com/stac-utils/stac-fastapi/compare/6.1.2..6.1.3>
690693
[6.1.2]: <https://github.com/stac-utils/stac-fastapi/compare/6.1.1..6.1.2>
691694
[6.1.1]: <https://github.com/stac-utils/stac-fastapi/compare/6.1.0..6.1.1>
692695
[6.1.0]: <https://github.com/stac-utils/stac-fastapi/compare/6.0.0..6.1.0>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.1.1
1+
6.1.3

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "stac-fastapi"
3-
version = "6.1.1"
3+
version = "6.1.3"
44
description = "Python library for building a STAC-compliant FastAPI application."
55
requires-python = ">=3.11"
66
readme = "README.md"
@@ -81,7 +81,7 @@ explicit_package_bases = true
8181
exclude = ["tests", ".venv"]
8282

8383
[tool.bumpversion]
84-
current_version = "6.1.1"
84+
current_version = "6.1.3"
8585
parse = """(?x)
8686
(?P<major>\\d+)\\.
8787
(?P<minor>\\d+)\\.

stac_fastapi/api/stac_fastapi/api/errors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def request_validation_exception_handler(
9393
status_code=status.HTTP_400_BAD_REQUEST,
9494
)
9595

96+
# TODO: Argument 2 to "add_exception_handler" of "Starlette" has incompatible type
9697
app.add_exception_handler(
97-
RequestValidationError, request_validation_exception_handler
98+
RequestValidationError,
99+
request_validation_exception_handler, # type: ignore
98100
)

stac_fastapi/api/stac_fastapi/api/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _get_forwarded_url_parts(self, scope: Scope) -> Tuple[str, str, str]:
8686
proto = scope.get("scheme", "http")
8787
header_host = self._get_header_value_by_name(scope, "host")
8888
if header_host is None:
89-
domain, port = scope.get("server")
89+
domain, port = scope["server"]
9090
else:
9191
header_host_parts = header_host.split(":")
9292
if len(header_host_parts) == 2:

stac_fastapi/api/stac_fastapi/api/models.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
import orjson # noqa
2525
from fastapi.responses import ORJSONResponse as JSONResponse
2626
except ImportError: # pragma: nocover
27-
from starlette.responses import JSONResponse
27+
from starlette.responses import JSONResponse # type: ignore
2828

2929

3030
def create_request_model(
3131
model_name="SearchGetRequest",
3232
base_model: Union[Type[BaseModel], Type[APIRequest]] = BaseSearchGetRequest,
3333
extensions: Optional[List[ApiExtension]] = None,
3434
mixins: Optional[Union[List[Type[BaseModel]], List[Type[APIRequest]]]] = None,
35-
request_type: Optional[str] = "GET",
35+
request_type: str = "GET",
3636
) -> Union[Type[BaseModel], Type[APIRequest]]:
3737
"""Create a pydantic model for validating request bodies."""
3838
fields = {}
39-
extension_models = []
39+
extension_models: List[Union[Type[BaseModel], Type[APIRequest]]] = []
4040

4141
# Check extensions for additional parameters to search
4242
for extension in extensions or []:
@@ -54,7 +54,7 @@ def create_request_model(
5454
# Handle POST requests
5555
elif all([issubclass(m, BaseModel) for m in models]):
5656
for model in models:
57-
for k, field_info in model.model_fields.items():
57+
for k, field_info in model.model_fields.items(): # type: ignore
5858
fields[k] = (field_info.annotation, field_info)
5959

6060
return create_model(model_name, **fields, __base__=base_model) # type: ignore
@@ -64,11 +64,10 @@ def create_request_model(
6464

6565
def create_get_request_model(
6666
extensions: Optional[List[ApiExtension]],
67-
base_model: BaseSearchGetRequest = BaseSearchGetRequest,
67+
base_model: Type[BaseSearchGetRequest] = BaseSearchGetRequest,
6868
) -> Type[APIRequest]:
6969
"""Wrap create_request_model to create the GET request model."""
70-
71-
return create_request_model(
70+
return create_request_model( # type: ignore
7271
"SearchGetRequest",
7372
base_model=base_model,
7473
extensions=extensions,
@@ -78,10 +77,10 @@ def create_get_request_model(
7877

7978
def create_post_request_model(
8079
extensions: Optional[List[ApiExtension]],
81-
base_model: BaseSearchPostRequest = BaseSearchPostRequest,
80+
base_model: Type[BaseSearchPostRequest] = BaseSearchPostRequest,
8281
) -> Type[BaseModel]:
8382
"""Wrap create_request_model to create the POST request model."""
84-
return create_request_model(
83+
return create_request_model( # type: ignore
8584
"SearchPostRequest",
8685
base_model=base_model,
8786
extensions=extensions,

stac_fastapi/api/stac_fastapi/api/openapi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ def update_openapi(app: FastAPI) -> FastAPI:
1414
content-type response header.
1515
"""
1616
# Find the route for the openapi_url in the app
17+
# TODO: Type info is Route, while it shoukd maybe be APIRoute? Check FastAPI source.
1718
openapi_route: Route = next(
18-
route for route in app.router.routes if route.path == app.openapi_url
19+
route
20+
for route in app.router.routes
21+
if route.path == app.openapi_url # type: ignore
1922
)
2023
# Store the old endpoint function so we can call it from the patched function
2124
old_endpoint = openapi_route.endpoint

stac_fastapi/api/stac_fastapi/api/routes.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from starlette.routing import BaseRoute, Match
1717
from starlette.status import HTTP_204_NO_CONTENT
1818

19-
from stac_fastapi.api.models import APIRequest
19+
from stac_fastapi.types.search import APIRequest
2020

2121

2222
def _wrap_response(resp: Any) -> Any:
@@ -58,7 +58,7 @@ async def _endpoint(request: Request, request_data: Dict[str, Any]):
5858

5959
elif issubclass(request_model, APIRequest):
6060

61-
async def _endpoint(request: Request, request_data=Depends(request_model)):
61+
async def _endpoint(request: Request, request_data=Depends(request_model)): # type: ignore
6262
"""Endpoint."""
6363
return _wrap_response(await func(request=request, **request_data.kwargs()))
6464

@@ -100,10 +100,14 @@ def add_route_dependencies(
100100
_scope = copy.deepcopy(scope)
101101
for route in routes:
102102
if scope["path"] == "*":
103-
_scope["path"] = route.path
103+
# NOTE: ignore type, because BaseRoute has no "path" attribute
104+
# but APIRoute does.
105+
_scope["path"] = route.path # type: ignore
104106

107+
# NOTE: ignore type, because BaseRoute has no "method" attribute
108+
# but APIRoute does.
105109
if scope["method"] == "*":
106-
_scope["method"] = list(route.methods)[0]
110+
_scope["method"] = list(route.methods)[0] # type: ignore
107111

108112
match, _ = route.matches({"type": "http", **_scope})
109113
if match != Match.FULL:
@@ -119,7 +123,10 @@ def add_route_dependencies(
119123
route.dependant.dependencies.insert(
120124
0,
121125
get_parameterless_sub_dependant(
122-
depends=depends, path=route.path_format
126+
# NOTE: ignore type, because BaseRoute has no "path_format"
127+
# attribute but APIRoute does.
128+
depends=depends,
129+
path=route.path_format, # type: ignore
123130
),
124131
)
125132

@@ -128,7 +135,9 @@ def add_route_dependencies(
128135
# app.include_router(router))
129136
# https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/applications.py#L337-L360
130137
# https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/routing.py#L677-L678
131-
route.dependencies.extend(dependencies)
138+
# NOTE: ignore type, because BaseRoute has no "dependencies" attribute
139+
# but APIRoute does.
140+
route.dependencies.extend(dependencies) # type: ignore
132141

133142

134143
def add_direct_response(app: FastAPI) -> None:

0 commit comments

Comments
 (0)