]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/black/src/blackd/middlewares.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '882d8795c6ff65c02f2657e596391748d1b6b7f5'
[etc/vim.git] / .vim / bundle / black / src / blackd / middlewares.py
index 97994ecc1dff81df44d81076534c9886e527bf1f..370e0ae222eebfef1b73c185b4fc6130e87974cc 100644 (file)
@@ -1,7 +1,18 @@
-from typing import Iterable, Awaitable, Callable
-from aiohttp.web_response import StreamResponse
+from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable, TypeVar
+
 from aiohttp.web_request import Request
-from aiohttp.web_middlewares import middleware
+from aiohttp.web_response import StreamResponse
+
+if TYPE_CHECKING:
+    F = TypeVar("F", bound=Callable[..., Any])
+    middleware: Callable[[F], F]
+else:
+    try:
+        from aiohttp.web_middlewares import middleware
+    except ImportError:
+        # @middleware is deprecated and its behaviour is the default since aiohttp 4.0
+        # so if it doesn't exist anymore, define a no-op for forward compatibility.
+        middleware = lambda x: x  # noqa: E731
 
 Handler = Callable[[Request], Awaitable[StreamResponse]]
 Middleware = Callable[[Request, Handler], Awaitable[StreamResponse]]
@@ -31,4 +42,4 @@ def cors(allow_headers: Iterable[str]) -> Middleware:
 
         return resp
 
-    return impl  # type: ignore
+    return impl