aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-03-27 23:22:28 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-03-27 23:22:28 +0100
commit27511447e1d2fbde6a6cd6832026d454e2c9718b (patch)
tree6e7198dba170a6d83f70afe3ef1005e215770bea
parentf1bba1369b7bd3836fd6e38cf1a3c4d7844feee5 (diff)
downloadpaste-27511447e1d2fbde6a6cd6832026d454e2c9718b.tar.gz
paste-27511447e1d2fbde6a6cd6832026d454e2c9718b.tar.xz
paste-27511447e1d2fbde6a6cd6832026d454e2c9718b.zip
move types into their own module
-rw-r--r--paste/__init__.py39
-rw-r--r--paste/types.py27
2 files changed, 38 insertions, 28 deletions
diff --git a/paste/__init__.py b/paste/__init__.py
index 099474a..567aa8e 100644
--- a/paste/__init__.py
+++ b/paste/__init__.py
@@ -3,34 +3,21 @@ import sys
import traceback
import urllib.parse
from base64 import b64decode, b64encode
-from collections.abc import Callable, Iterable
+from collections.abc import Callable
from functools import wraps
-from typing import Any, Optional, Protocol, runtime_checkable
+from typing import Optional
from wsgiref.util import application_uri, request_uri
from . import store
-
-
-@runtime_checkable
-class Closable(Protocol):
- def close(self):
- ...
-
-
-class StartResponse(Protocol):
- def __call__(
- self,
- status: str,
- headers: list[tuple[str, str]],
- exc_info: Optional[tuple] = ...,
- /,
- ) -> Callable[[bytes], object]:
- ...
-
-
-Env = dict[str, Any]
-App = Callable[[Env, StartResponse], Iterable[bytes]]
-Response = Iterable[bytes]
+from .types import (
+ App,
+ Closable,
+ Env,
+ Middleware,
+ ProtoMiddleware,
+ Response,
+ StartResponse,
+)
DB_PATH = "paste.sqlite3"
@@ -54,10 +41,6 @@ def simple_response(
return [body]
-ProtoMiddleware = Callable[[App, Env, StartResponse], Response]
-Middleware = Callable[[App], App]
-
-
def middleware(f: ProtoMiddleware) -> Middleware:
@wraps(f)
def outer(app: App):
diff --git a/paste/types.py b/paste/types.py
new file mode 100644
index 0000000..0170c17
--- /dev/null
+++ b/paste/types.py
@@ -0,0 +1,27 @@
+from collections.abc import Callable, Iterable
+from typing import Any, Optional, Protocol, runtime_checkable
+
+
+@runtime_checkable
+class Closable(Protocol):
+ def close(self):
+ ...
+
+
+class StartResponse(Protocol):
+ def __call__(
+ self,
+ status: str,
+ headers: list[tuple[str, str]],
+ exc_info: Optional[tuple] = ...,
+ /,
+ ) -> Callable[[bytes], object]:
+ ...
+
+
+Env = dict[str, Any]
+App = Callable[[Env, StartResponse], Iterable[bytes]]
+Response = Iterable[bytes]
+
+ProtoMiddleware = Callable[[App, Env, StartResponse], Response]
+Middleware = Callable[[App], App]