Skip to content

Commit

Permalink
Type fixes for starlette 0.34.0
Browse files Browse the repository at this point in the history
Starlette removed some Any annotations in 0.34.0.
Issue tracked in abersheeran/a2wsgi#44
  • Loading branch information
mvdbeek committed Jan 1, 2024
1 parent 87eabd0 commit 242f75c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/galaxy/webapps/galaxy/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Any,
AsyncGenerator,
cast,
MutableMapping,
NamedTuple,
Optional,
Tuple,
Expand All @@ -21,6 +20,7 @@
)

from a2wsgi.wsgi import build_environ
from a2wsgi.wsgi_typing import Environ
from fastapi import (
APIRouter,
Form,
Expand Down Expand Up @@ -205,7 +205,7 @@ class GalaxyASGIRequest(GalaxyAbstractRequest):

def __init__(self, request: Request):
self.__request = request
self.__environ: Optional[MutableMapping[str, Any]] = None
self.__environ: Optional[Environ] = None

@property
def base(self) -> str:
Expand All @@ -224,7 +224,7 @@ def host(self) -> str:
return self.__request.base_url.netloc

@property
def environ(self) -> MutableMapping[str, Any]:
def environ(self) -> Environ:
"""
Fallback WSGI environ.
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/fast_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def initialize_fast_app(gx_wsgi_webapp, gx_app):
include_legacy_openapi(app, gx_app)
wsgi_handler = WSGIMiddleware(gx_wsgi_webapp)
gx_app.haltables.append(("WSGI Middleware threadpool", wsgi_handler.executor.shutdown))
app.mount("/", wsgi_handler)
app.mount("/", wsgi_handler) # type: ignore[arg-type]
if gx_app.config.galaxy_url_prefix != "/":
parent_app = FastAPI()
parent_app.mount(gx_app.config.galaxy_url_prefix, app=app)
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/reports/fast_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ def initialize_fast_app(gx_webapp):
add_request_id_middleware(app)
include_all_package_routers(app, "galaxy.webapps.reports.api")
wsgi_handler = WSGIMiddleware(gx_webapp)
app.mount("/", wsgi_handler)
# https://github.com/abersheeran/a2wsgi/issues/44
app.mount("/", wsgi_handler) # type: ignore[arg-type]
return app
3 changes: 2 additions & 1 deletion lib/tool_shed/webapp/fast_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def mount_static(directory: Path):
include_all_package_routers(app, routes_package)
wsgi_handler = WSGIMiddleware(gx_webapp)
tool_shed_app.haltables.append(("WSGI Middleware threadpool", wsgi_handler.executor.shutdown))
app.mount("/", wsgi_handler)
# https://github.com/abersheeran/a2wsgi/issues/44
app.mount("/", wsgi_handler) # type: ignore[arg-type]
return app


Expand Down
3 changes: 2 additions & 1 deletion test/unit/webapps/test_send_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def wsgi_application(env, start_response):
return send_file(start_response, trans, fh)

app = FastAPI()
app.mount("/test/send_file", WSGIMiddleware(wsgi_application))
# https://github.com/abersheeran/a2wsgi/issues/44
app.mount("/test/send_file", WSGIMiddleware(wsgi_application)) # type: ignore[arg-type]
return app


Expand Down

0 comments on commit 242f75c

Please sign in to comment.