Skip to content

Commit 6a67f9c

Browse files
committed
chore: | for union types since >=py310
1 parent fb5f2ef commit 6a67f9c

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/stac_auth_proxy/middleware/AuthenticationExtensionMiddleware.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import re
55
from dataclasses import dataclass, field
6-
from typing import Any, Sequence, Union
6+
from typing import Any, Sequence
77
from urllib.parse import urlparse
88

99
from starlette.datastructures import Headers
@@ -35,8 +35,8 @@ class AuthenticationExtensionMiddleware(JsonResponseMiddleware):
3535
"https://stac-extensions.github.io/authentication/v1.1.0/schema.json"
3636
)
3737

38-
items_filter_path: Union[str, Sequence[str], None] = None
39-
collections_filter_path: Union[str, Sequence[str], None] = None
38+
items_filter_path: str | Sequence[str] | None = None
39+
collections_filter_path: str | Sequence[str] | None = None
4040
root_path: str = ""
4141

4242
json_content_type_expr: str = r"application/(geo\+)?json"

src/stac_auth_proxy/middleware/Cql2BuildFilterMiddleware.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import re
55
from dataclasses import dataclass
6-
from typing import Any, Awaitable, Callable, Optional, Sequence, Union
6+
from typing import Any, Awaitable, Callable, Optional, Sequence
77

88
from cql2 import Expr, ValidationError
99
from fastapi import HTTPException
@@ -32,11 +32,11 @@ class Cql2BuildFilterMiddleware:
3232

3333
# Filters
3434
collections_filter: Optional[Callable] = None
35-
collections_filter_path: Union[str, Sequence[str]] = (
35+
collections_filter_path: str | Sequence[str] = (
3636
r"^/collections(?:/(?P<collection_id>[^/]+))?$",
3737
)
3838
items_filter: Optional[Callable] = None
39-
items_filter_path: Union[str, Sequence[str]] = (
39+
items_filter_path: str | Sequence[str] = (
4040
r"^(?:/collections/(?P<collection_id>[^/]+)/items(?:/(?P<item_id>[^/]+))?|/search)$",
4141
)
4242

src/stac_auth_proxy/middleware/UpdateOpenApiMiddleware.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import re
44
from dataclasses import dataclass
5-
from typing import Any, Optional, Sequence, Union
5+
from typing import Any, Optional, Sequence
66

77
from starlette.datastructures import Headers
88
from starlette.requests import Request
@@ -28,8 +28,8 @@ class OpenApiMiddleware(JsonResponseMiddleware):
2828
auth_scheme_name: str = "oidcAuth"
2929
auth_scheme_override: Optional[dict] = None
3030

31-
items_filter_path: Union[str, Sequence[str], None] = None
32-
collections_filter_path: Union[str, Sequence[str], None] = None
31+
items_filter_path: str | Sequence[str] | None = None
32+
collections_filter_path: str | Sequence[str] | None = None
3333

3434
json_content_type_expr: str = r"application/(vnd\.oai\.openapi\+json?|json)"
3535

src/stac_auth_proxy/utils/requests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
import re
66
from dataclasses import dataclass, field
7-
from typing import Dict, Optional, Sequence, Union
7+
from typing import Dict, Optional, Sequence
88
from urllib.parse import urlparse
99

1010
from starlette.requests import Request
@@ -26,7 +26,7 @@ def extract_variables(url: str) -> dict:
2626
return {k: v for k, v in match.groupdict().items() if v} if match else {}
2727

2828

29-
def as_patterns(value: Union[str, Sequence[str], None]) -> Sequence[str]:
29+
def as_patterns(value: str | Sequence[str] | None) -> Sequence[str]:
3030
"""Normalize a filter path setting to a list of regex patterns."""
3131
if value is None:
3232
return []
@@ -63,8 +63,8 @@ def find_match(
6363
private_endpoints: EndpointMethods,
6464
public_endpoints: EndpointMethods,
6565
default_public: bool,
66-
items_filter_path: Union[str, Sequence[str], None] = None,
67-
collections_filter_path: Union[str, Sequence[str], None] = None,
66+
items_filter_path: str | Sequence[str] | None = None,
67+
collections_filter_path: str | Sequence[str] | None = None,
6868
) -> "MatchResult":
6969
"""Check if the given path and method match any of the regex patterns and methods in the endpoints."""
7070
primary_endpoints = private_endpoints if default_public else public_endpoints

0 commit comments

Comments
 (0)