Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix importing Middleware type alias #185

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/aiohttp_middlewares/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

"""

import importlib

from typing import (
Any,
Awaitable,
Expand All @@ -19,9 +21,15 @@
)

from aiohttp import web
from aiohttp.web_middlewares import _Middleware as Middleware
from yarl import URL

try:
# (<3.9.0) Try to import Middleware from aiohttp.web_middlewares
Middleware = importlib.import_module('aiohttp.web_middlewares')._Middleware
except AttributeError:
# (>=3.9.0) If that fails, import Middleware from aiohttp.typedefs
Middleware = importlib.import_module('aiohttp.typedefs').Middleware

mprasil marked this conversation as resolved.
Show resolved Hide resolved

# Make flake8 happy
(Middleware,)
Expand Down