Skip to content

Commit 145c2f0

Browse files
Update mypy (#895)
* catalogs extension scratch * import fixes * pre-commit * update mypy * update changelog * remove old code * removals * shorten line? * lint * fix invalid_intervals * fix type --------- Co-authored-by: vincentsarago <vincent.sarago@gmail.com>
1 parent 5a1e78f commit 145c2f0

12 files changed

Lines changed: 54 additions & 56 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: "v0.2.2"
3+
rev: "v0.15.8"
44
hooks:
55
- id: ruff
66
args: [--fix, --exit-non-zero-on-fix]
77
- id: ruff-format
88

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

‎CHANGES.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- 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))
8+
59
## [6.2.1] - 2026-02-10
610

711
### Fixed

‎stac_fastapi/api/stac_fastapi/api/app.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Fastapi app creation."""
22

3-
43
import inspect
54
from typing import Awaitable, Callable, Dict, List, Optional, Tuple, Type, Union
65

‎stac_fastapi/api/tests/test_api.py‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def _assert_dependency_applied(api, routes):
3939
with TestClient(api.app) as client:
4040
for route in routes:
4141
response = getattr(client, route["method"].lower())(route["path"])
42-
assert (
43-
response.status_code == 401
44-
), "Unauthenticated requests should be rejected"
42+
assert response.status_code == 401, (
43+
"Unauthenticated requests should be rejected"
44+
)
4545
assert response.json() == {"detail": "Not authenticated"}
4646

4747
path = route["path"].format(
@@ -54,9 +54,9 @@ def _assert_dependency_applied(api, routes):
5454
content=route["payload"],
5555
headers={"content-type": "application/json"},
5656
)
57-
assert (
58-
200 <= response.status_code < 300
59-
), "Authenticated requests should be accepted"
57+
assert 200 <= response.status_code < 300, (
58+
"Authenticated requests should be accepted"
59+
)
6060
assert response.json() == "dummy response"
6161

6262
@staticmethod
@@ -72,9 +72,9 @@ def _assert_dependency_not_applied(api, routes):
7272
content=route["payload"],
7373
headers={"content-type": "application/json"},
7474
)
75-
assert (
76-
200 <= response.status_code < 300
77-
), "Authenticated requests should be accepted"
75+
assert 200 <= response.status_code < 300, (
76+
"Authenticated requests should be accepted"
77+
)
7878
assert response.json() == "dummy response"
7979

8080
def test_openapi_content_type(self):
@@ -400,23 +400,17 @@ def test_add_default_method_route_dependencies_after_building_api(
400400

401401

402402
class DummyCoreClient(core.BaseCoreClient):
403-
def all_collections(self, *args, **kwargs):
404-
...
403+
def all_collections(self, *args, **kwargs): ...
405404

406-
def get_collection(self, *args, **kwargs):
407-
...
405+
def get_collection(self, *args, **kwargs): ...
408406

409-
def get_item(self, *args, **kwargs):
410-
...
407+
def get_item(self, *args, **kwargs): ...
411408

412-
def get_search(self, *args, **kwargs):
413-
...
409+
def get_search(self, *args, **kwargs): ...
414410

415-
def post_search(self, *args, **kwargs):
416-
...
411+
def post_search(self, *args, **kwargs): ...
417412

418-
def item_collection(self, *args, **kwargs):
419-
...
413+
def item_collection(self, *args, **kwargs): ...
420414

421415

422416
class DummyTransactionsClient(BaseTransactionsClient):

‎stac_fastapi/api/tests/test_app_prefix.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
def get_link(landing_page, rel_type, method: Optional[str] = None):
1313
return next(
1414
filter(
15-
lambda link: link["rel"] == rel_type
16-
and (not method or link.get("method") == method),
15+
lambda link: (
16+
link["rel"] == rel_type and (not method or link.get("method") == method)
17+
),
1718
landing_page["links"],
1819
),
1920
None,

‎stac_fastapi/extensions/stac_fastapi/extensions/core/aggregation/aggregation.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Aggregation Extension."""
2+
23
from enum import Enum
34
from typing import List, Type, Union
45

‎stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# encoding: utf-8
22
"""Filter Extension."""
3+
34
from enum import Enum
45
from typing import List, Type, Union
56

‎stac_fastapi/extensions/stac_fastapi/extensions/core/transaction/transaction.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Transaction extension."""
22

33
from enum import Enum
4-
from typing import List, Optional, Type, Union
4+
from typing import Any, Dict, List, Optional, Type, Union
55

66
import attr
77
from fastapi import APIRouter, Body, FastAPI
@@ -108,7 +108,10 @@ class PatchCollection(CollectionUri):
108108
]
109109
}
110110
# ref: https://github.com/pydantic/pydantic/issues/889
111-
_patch_item_schema["items"]["anyOf"] = list(_patch_item_schema["$defs"].values())
111+
_patch_item_schema_dict: Dict[str, Any] = _patch_item_schema
112+
_patch_item_schema_dict["items"]["anyOf"] = list(
113+
_patch_item_schema_dict["$defs"].values()
114+
)
112115

113116
_patch_collection_schema = TypeAdapter(List[PatchOperation]).json_schema() | {
114117
"examples": [
@@ -146,8 +149,9 @@ class PatchCollection(CollectionUri):
146149
]
147150
}
148151
# ref: https://github.com/pydantic/pydantic/issues/889
149-
_patch_collection_schema["items"]["anyOf"] = list(
150-
_patch_collection_schema["$defs"].values()
152+
_patch_collection_schema_dict: Dict[str, Any] = _patch_collection_schema
153+
_patch_collection_schema_dict["items"]["anyOf"] = list(
154+
_patch_collection_schema_dict["$defs"].values()
151155
)
152156

153157

‎stac_fastapi/extensions/tests/test_free_text.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# noqa: E501
22
"""test freetext extension."""
33

4-
54
from starlette.testclient import TestClient
65

76
from stac_fastapi.api.app import StacApi

‎stac_fastapi/types/stac_fastapi/types/search.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
"""stac_fastapi.types.search module.
1+
"""stac_fastapi.types.search module."""
22

3-
"""
43
from datetime import datetime as dt
54
from typing import Dict, List, Optional, Union, cast
65

0 commit comments

Comments
 (0)