Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.2"
rev: "v0.15.8"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.0
rev: v1.20.0
hooks:
- id: mypy
language_version: python
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- fix mypy type errors in transaction extension for Python 3.14 compatibility (mypy 1.20.0) ([#895](https://github.com/stac-utils/stac-fastapi/pull/895))

## [6.2.1] - 2026-02-10

### Fixed
Expand Down
1 change: 0 additions & 1 deletion stac_fastapi/api/stac_fastapi/api/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Fastapi app creation."""


import inspect
from typing import Awaitable, Callable, Dict, List, Optional, Tuple, Type, Union

Expand Down
36 changes: 15 additions & 21 deletions stac_fastapi/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def _assert_dependency_applied(api, routes):
with TestClient(api.app) as client:
for route in routes:
response = getattr(client, route["method"].lower())(route["path"])
assert (
response.status_code == 401
), "Unauthenticated requests should be rejected"
assert response.status_code == 401, (
"Unauthenticated requests should be rejected"
)
assert response.json() == {"detail": "Not authenticated"}

path = route["path"].format(
Expand All @@ -54,9 +54,9 @@ def _assert_dependency_applied(api, routes):
content=route["payload"],
headers={"content-type": "application/json"},
)
assert (
200 <= response.status_code < 300
), "Authenticated requests should be accepted"
assert 200 <= response.status_code < 300, (
"Authenticated requests should be accepted"
)
assert response.json() == "dummy response"

@staticmethod
Expand All @@ -72,9 +72,9 @@ def _assert_dependency_not_applied(api, routes):
content=route["payload"],
headers={"content-type": "application/json"},
)
assert (
200 <= response.status_code < 300
), "Authenticated requests should be accepted"
assert 200 <= response.status_code < 300, (
"Authenticated requests should be accepted"
)
assert response.json() == "dummy response"

def test_openapi_content_type(self):
Expand Down Expand Up @@ -400,23 +400,17 @@ def test_add_default_method_route_dependencies_after_building_api(


class DummyCoreClient(core.BaseCoreClient):
def all_collections(self, *args, **kwargs):
...
def all_collections(self, *args, **kwargs): ...

def get_collection(self, *args, **kwargs):
...
def get_collection(self, *args, **kwargs): ...

def get_item(self, *args, **kwargs):
...
def get_item(self, *args, **kwargs): ...

def get_search(self, *args, **kwargs):
...
def get_search(self, *args, **kwargs): ...

def post_search(self, *args, **kwargs):
...
def post_search(self, *args, **kwargs): ...

def item_collection(self, *args, **kwargs):
...
def item_collection(self, *args, **kwargs): ...


class DummyTransactionsClient(BaseTransactionsClient):
Expand Down
5 changes: 3 additions & 2 deletions stac_fastapi/api/tests/test_app_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
def get_link(landing_page, rel_type, method: Optional[str] = None):
return next(
filter(
lambda link: link["rel"] == rel_type
and (not method or link.get("method") == method),
lambda link: (
link["rel"] == rel_type and (not method or link.get("method") == method)
),
landing_page["links"],
),
None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Aggregation Extension."""

from enum import Enum
from typing import List, Type, Union

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# encoding: utf-8
"""Filter Extension."""

from enum import Enum
from typing import List, Type, Union

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Transaction extension."""

from enum import Enum
from typing import List, Optional, Type, Union
from typing import Any, List, Optional, Type, Union

import attr
from fastapi import APIRouter, Body, FastAPI
Expand Down Expand Up @@ -108,7 +108,10 @@ class PatchCollection(CollectionUri):
]
}
# ref: https://github.com/pydantic/pydantic/issues/889
_patch_item_schema["items"]["anyOf"] = list(_patch_item_schema["$defs"].values())
_patch_item_schema_dict: Any = _patch_item_schema
Comment thread
vincentsarago marked this conversation as resolved.
Outdated
_patch_item_schema_dict["items"]["anyOf"] = list(
_patch_item_schema_dict["$defs"].values()
)

_patch_collection_schema = TypeAdapter(List[PatchOperation]).json_schema() | {
"examples": [
Expand Down Expand Up @@ -146,8 +149,9 @@ class PatchCollection(CollectionUri):
]
}
# ref: https://github.com/pydantic/pydantic/issues/889
_patch_collection_schema["items"]["anyOf"] = list(
_patch_collection_schema["$defs"].values()
_patch_collection_schema_dict: Any = _patch_collection_schema
Comment thread
vincentsarago marked this conversation as resolved.
Outdated
_patch_collection_schema_dict["items"]["anyOf"] = list(
_patch_collection_schema_dict["$defs"].values()
)


Expand Down
1 change: 0 additions & 1 deletion stac_fastapi/extensions/tests/test_free_text.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# noqa: E501
"""test freetext extension."""


from starlette.testclient import TestClient

from stac_fastapi.api.app import StacApi
Expand Down
3 changes: 1 addition & 2 deletions stac_fastapi/types/stac_fastapi/types/search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""stac_fastapi.types.search module.
"""stac_fastapi.types.search module."""

"""
from datetime import datetime as dt
from typing import Dict, List, Optional, Union, cast

Expand Down
38 changes: 19 additions & 19 deletions stac_fastapi/types/tests/test_rfc3339.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
]

invalid_intervals = [
"/"
"../"
"/.."
"../.."
"/",
"../",
"/..",
"../..",
"/1984-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z", # extra start /
"1984-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z/", # extra end /
"1986-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z", # start > end
Expand Down Expand Up @@ -89,39 +89,39 @@ def test_parse_valid_str_to_datetime(test_input):
def test_str_to_interval_with_invalid_interval(test_input):
with pytest.raises(HTTPException) as exc_info:
str_to_interval(test_input)
assert (
exc_info.value.status_code == 400
), "str_to_interval should return a 400 status code for invalid interval"
assert exc_info.value.status_code == 400, (
"str_to_interval should return a 400 status code for invalid interval"
)


@pytest.mark.parametrize("test_input", invalid_datetimes)
def test_str_to_interval_with_invalid_datetime(test_input):
with pytest.raises(HTTPException) as exc_info:
str_to_interval(test_input)
assert (
exc_info.value.status_code == 400
), "str_to_interval should return a 400 status code for invalid datetime"
assert exc_info.value.status_code == 400, (
"str_to_interval should return a 400 status code for invalid datetime"
)


@pytest.mark.parametrize("test_input", valid_intervals)
def test_str_to_interval_with_valid_interval(test_input):
assert isinstance(
str_to_interval(test_input), tuple
), "str_to_interval should return tuple for multi-value input"
assert isinstance(str_to_interval(test_input), tuple), (
"str_to_interval should return tuple for multi-value input"
)


@pytest.mark.parametrize("test_input", valid_datetimes)
def test_str_to_interval_with_valid_datetime(test_input):
assert isinstance(
str_to_interval(test_input), datetime
), "str_to_interval should return single datetime for single-value input"
assert isinstance(str_to_interval(test_input), datetime), (
"str_to_interval should return single datetime for single-value input"
)


def test_str_to_interval_with_none():
"""Test that str_to_interval returns None when provided with None."""
assert (
str_to_interval(None) is None
), "str_to_interval should return None when input is None"
assert str_to_interval(None) is None, (
"str_to_interval should return None when input is None"
)


def test_now_functions() -> None:
Expand Down
4 changes: 0 additions & 4 deletions uv.lock

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