forked from Shifty/pyserveX
lint fixes
This commit is contained in:
parent
3454801be7
commit
edaccb59bb
@ -11,7 +11,9 @@ The WSGI app path is passed via environment variables:
|
|||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
|
WSGI_ADAPTER: Optional[str] = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from a2wsgi import WSGIMiddleware
|
from a2wsgi import WSGIMiddleware
|
||||||
@ -27,7 +29,7 @@ except ImportError:
|
|||||||
WSGI_ADAPTER = None
|
WSGI_ADAPTER = None
|
||||||
|
|
||||||
|
|
||||||
def _load_wsgi_app() -> Callable:
|
def _load_wsgi_app() -> Callable[..., Any]:
|
||||||
app_path = os.environ.get("PYSERVE_WSGI_APP")
|
app_path = os.environ.get("PYSERVE_WSGI_APP")
|
||||||
is_factory = os.environ.get("PYSERVE_WSGI_FACTORY", "0") == "1"
|
is_factory = os.environ.get("PYSERVE_WSGI_FACTORY", "0") == "1"
|
||||||
|
|
||||||
@ -51,8 +53,9 @@ def _load_wsgi_app() -> Callable:
|
|||||||
raise RuntimeError(f"Module '{module_name}' has no attribute '{attr_name}'")
|
raise RuntimeError(f"Module '{module_name}' has no attribute '{attr_name}'")
|
||||||
|
|
||||||
if is_factory:
|
if is_factory:
|
||||||
return app_or_factory()
|
result: Callable[..., Any] = app_or_factory()
|
||||||
return app_or_factory
|
return result
|
||||||
|
return app_or_factory # type: ignore[return-value]
|
||||||
|
|
||||||
|
|
||||||
def _create_asgi_app() -> Any:
|
def _create_asgi_app() -> Any:
|
||||||
|
|||||||
@ -223,7 +223,7 @@ class ExtensionManager:
|
|||||||
try:
|
try:
|
||||||
from .process_extension import ProcessOrchestrationExtension
|
from .process_extension import ProcessOrchestrationExtension
|
||||||
|
|
||||||
self.extension_registry["process_orchestration"] = ProcessOrchestrationExtension # type: ignore
|
self.extension_registry["process_orchestration"] = ProcessOrchestrationExtension
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass # Optional dependency
|
pass # Optional dependency
|
||||||
|
|
||||||
|
|||||||
@ -152,9 +152,10 @@ class PyServeServer:
|
|||||||
|
|
||||||
def _create_app(self) -> None:
|
def _create_app(self) -> None:
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
from typing import AsyncIterator
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: Starlette):
|
async def lifespan(app: Starlette) -> AsyncIterator[None]:
|
||||||
await self._load_async_extensions()
|
await self._load_async_extensions()
|
||||||
logger.info("Async extensions loaded")
|
logger.info("Async extensions loaded")
|
||||||
yield
|
yield
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user