Skip to content

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeSneyders committed Oct 6, 2023
1 parent 38f64d8 commit 2eec92f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion connexion/apps/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AsyncMiddlewareApp(RoutedMiddleware[AsyncApi]):
api_cls = AsyncApi

def __init__(self) -> None:
self.apis: t.Dict[str, AsyncApi] = {}
self.apis: t.Dict[str, t.List[AsyncApi]] = {}
self.operations: t.Dict[str, AsyncOperation] = {}
self.router = Router()
super().__init__(self.router)
Expand Down
2 changes: 1 addition & 1 deletion connexion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
try:
import importlib_metadata
except ImportError:
import importlib.metadata as importlib_metadata
import importlib.metadata as importlib_metadata # type: ignore

logger = logging.getLogger("connexion.cli")

Expand Down
4 changes: 3 additions & 1 deletion connexion/middleware/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ def add_api(
security_map=security_map,
)

api = API(specification, base_path=base_path, name=name, **options.__dict__, **kwargs)
api = API(
specification, base_path=base_path, name=name, **options.__dict__, **kwargs
)
self.apis.append(api)

def add_error_handler(
Expand Down
5 changes: 4 additions & 1 deletion connexion/middleware/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def add_api(
# default. This way, if no matching route is found on the first API, the request is
# forwarded to the new API.
for route in self.router.routes:
if isinstance(route, starlette.routing.Mount) and route.path == api.base_path:
if (
isinstance(route, starlette.routing.Mount)
and route.path == api.base_path
):
route.app.default = api.router

self.router.mount(api.base_path, app=api.router)
Expand Down
2 changes: 1 addition & 1 deletion connexion/middleware/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__(
if auth_all_paths:
self.add_auth_on_not_found()
else:
self.operations: t.MutableMapping[str, SecurityOperation] = {}
self.operations: t.MutableMapping[t.Optional[str], SecurityOperation] = {}

self.add_paths()

Expand Down
7 changes: 5 additions & 2 deletions tests/api/test_bootstrap_multiple_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@


@pytest.mark.parametrize("specs", SPECS)
def test_app_with_multiple_definition(multiple_yaml_same_basepath_dir, specs, app_class):
def test_app_with_multiple_definition(
multiple_yaml_same_basepath_dir, specs, app_class
):
app = app_class(
__name__,
specification_dir=".." / multiple_yaml_same_basepath_dir.relative_to(TEST_FOLDER),
specification_dir=".."
/ multiple_yaml_same_basepath_dir.relative_to(TEST_FOLDER),
)

for spec in specs:
Expand Down

0 comments on commit 2eec92f

Please sign in to comment.