Skip to content

Commit dd80e74

Browse files
committed
ci: lint fix
1 parent 909bc35 commit dd80e74

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/stac_auth_proxy/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from .config import Settings
1515
from .handlers import HealthzHandler, ReverseProxyHandler, SwaggerUI
16+
from .lifespan import lifespan
1617
from .middleware import (
1718
AddProcessTimeHeaderMiddleware,
1819
AuthenticationExtensionMiddleware,
@@ -25,7 +26,6 @@
2526
ProcessLinksMiddleware,
2627
RemoveRootPathMiddleware,
2728
)
28-
from .lifespan import lifespan
2929

3030
logger = logging.getLogger(__name__)
3131

@@ -135,6 +135,8 @@ def configure_app(app: FastAPI, settings: Optional[Settings] = None) -> FastAPI:
135135
)
136136

137137
return app
138+
139+
138140
def create_app(settings: Optional[Settings] = None) -> FastAPI:
139141
"""FastAPI Application Factory."""
140142
settings = settings or Settings()

src/stac_auth_proxy/lifespan.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Reusable lifespan handler for FastAPI applications."""
22

3-
from contextlib import asynccontextmanager
43
import logging
4+
from contextlib import asynccontextmanager
55
from typing import Any
66

77
from fastapi import FastAPI
@@ -13,7 +13,8 @@
1313

1414

1515
def lifespan(settings: Settings | None = None, **settings_kwargs: Any):
16-
"""Create a lifespan handler that runs startup checks.
16+
"""
17+
Create a lifespan handler that runs startup checks.
1718
1819
Parameters
1920
----------
@@ -29,13 +30,13 @@ def lifespan(settings: Settings | None = None, **settings_kwargs: Any):
2930
Callable[[FastAPI], AsyncContextManager[Any]]
3031
A callable suitable for the ``lifespan`` parameter of ``FastAPI``.
3132
"""
32-
3333
if settings is None:
3434
settings = Settings(**settings_kwargs)
35-
assert settings is not None
3635

3736
@asynccontextmanager
3837
async def _lifespan(app: FastAPI):
38+
assert settings is not None # Required for type checking
39+
3940
# Wait for upstream servers to become available
4041
if settings.wait_for_upstream:
4142
logger.info("Running upstream server health checks...")
@@ -62,4 +63,3 @@ async def _lifespan(app: FastAPI):
6263

6364

6465
__all__ = ["lifespan", "check_conformance", "check_server_health"]
65-

tests/test_lifespan.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
from starlette.middleware import Middleware
1010
from starlette.types import ASGIApp
1111

12-
from stac_auth_proxy import (
13-
check_conformance,
14-
check_server_health,
15-
lifespan as lifespan_handler,
16-
)
12+
from stac_auth_proxy import check_conformance, check_server_health
13+
from stac_auth_proxy import lifespan as lifespan_handler
1714
from stac_auth_proxy.utils.middleware import required_conformance
1815

1916

@@ -109,6 +106,4 @@ def test_lifespan_reusable():
109106
pass
110107
assert mock_health.await_count == 2
111108
expected_upstream = upstream_url.rstrip("/") + "/"
112-
mock_conf.assert_awaited_once_with(
113-
app.user_middleware, expected_upstream
114-
)
109+
mock_conf.assert_awaited_once_with(app.user_middleware, expected_upstream)

0 commit comments

Comments
 (0)