Skip to content

Commit 831ee3d

Browse files
committed
Add docstring for pre-commit
1 parent dd1f2ee commit 831ee3d

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

src/stac_auth_proxy/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212

1313
class ClassInput(BaseModel):
14+
"""Input model for dynamically loading a class or function."""
15+
1416
cls: str
1517
args: Optional[Sequence[str]] = []
1618
kwargs: Optional[dict[str, str]] = {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Module to define the access policy guards for the application."""
2+
13
from .cel import cel
24

35
__all__ = ["cel"]

src/stac_auth_proxy/guards/cel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Guard using CEL (Common Expression Language, https://cel.dev)."""
2+
13
from typing import Any, Callable
24

35
import celpy
@@ -7,7 +9,7 @@
79

810

911
def cel(expression: str, token_dependency: Callable[..., Any]):
10-
"""Custom middleware."""
12+
"""Cel check factory."""
1113
env = celpy.Environment()
1214
ast = env.compile(expression)
1315
program = env.program(ast)

src/stac_auth_proxy/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def safe_headers(headers: Headers) -> dict[str, str]:
2020

2121

2222
def extract_variables(url: str) -> dict:
23+
"""
24+
Extract variables from a URL path. Being that we use a catch-all endpoint for the proxy,
25+
we can't rely on the path parameters that FastAPI provides.
26+
"""
2327
path = urlparse(url).path
2428
# This allows either /items or /bulk_items, with an optional item_id following.
2529
pattern = r"^/collections/(?P<collection_id>[^/]+)(?:/(?:items|bulk_items)(?:/(?P<item_id>[^/]+))?)?/?$"

tests/test_guards_cel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def test_guard_query_params(
2727
endpoint,
2828
expected_status_code,
2929
):
30+
"""Test guard with query parameters."""
3031
app = app_factory(
3132
upstream_url=source_api_server,
3233
guard={
@@ -55,6 +56,7 @@ def test_guard_auth_token(
5556
token_payload,
5657
expected_status_code,
5758
):
59+
"""Test guard with auth token."""
5860
app = app_factory(
5961
upstream_url=source_api_server,
6062
guard={

tests/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
),
1818
)
1919
def test_extract_variables(url, expected):
20+
"""Test extracting variables from a URL path."""
2021
assert extract_variables(url) == expected

0 commit comments

Comments
 (0)