aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-04-04 22:42:44 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-04-04 22:43:21 +0100
commit83697ed2e0bbadfd79607e349049861dd4d764d3 (patch)
tree7e44473e60025769e11f6cedcf0760a36147e973
parente4c4db197c1ac3c51f9e3db553689d9c1f9614df (diff)
downloadpaste-83697ed2e0bbadfd79607e349049861dd4d764d3.tar.gz
paste-83697ed2e0bbadfd79607e349049861dd4d764d3.tar.xz
paste-83697ed2e0bbadfd79607e349049861dd4d764d3.zip
Make the main module succeed a strict pyright check
-rw-r--r--paste/__init__.py10
-rw-r--r--paste/db.py4
-rw-r--r--paste/types.py2
-rw-r--r--pyproject.toml5
4 files changed, 13 insertions, 8 deletions
diff --git a/paste/__init__.py b/paste/__init__.py
index 4e0a0ef..1536f02 100644
--- a/paste/__init__.py
+++ b/paste/__init__.py
@@ -5,7 +5,7 @@ import urllib.parse
from base64 import b64decode, b64encode
from collections.abc import Callable
from functools import wraps
-from typing import Optional
+from typing import Any, Optional
from wsgiref.util import application_uri, request_uri
from . import db
@@ -26,8 +26,8 @@ DB_PATH = "paste.sqlite3"
def simple_response(
start_response: StartResponse,
status: str,
- extra_headers: list = list(),
- exc_info: Optional[tuple] = None,
+ extra_headers: list[tuple[str, str]] = list(),
+ exc_info: Optional[tuple[Any, Any, Any]] = None,
) -> Response:
body = (status + "\n").encode()
start_response(
@@ -89,7 +89,7 @@ def if_none_match(app: App, environ: Env, start_response: StartResponse) -> Resp
def head_start_response(
status: str,
headers: list[tuple[str, str]],
- exc_info: Optional[tuple] = None,
+ exc_info: Optional[tuple[Any, Any, Any]] = None,
) -> Callable[[bytes], object]:
_, _ = status, exc_info
nonlocal etag
@@ -253,6 +253,6 @@ middlewares = [
authenticate(lambda environ: Auth(environ["paste.db_conn"])),
]
-application = paste_application
+application: App = paste_application
for m in reversed(middlewares):
application = m(application)
diff --git a/paste/db.py b/paste/db.py
index ab25e5f..e76d5e1 100644
--- a/paste/db.py
+++ b/paste/db.py
@@ -3,7 +3,7 @@ from collections.abc import Iterator
from contextlib import contextmanager
from hashlib import blake2b, sha256
from itertools import count
-from typing import Optional, Union
+from typing import Any, Optional, Union
migrations = [
"""CREATE TABLE file (
@@ -111,7 +111,7 @@ def migrate(connection: sqlite3.Connection, migrations: list[str]) -> None:
@contextmanager
def connect(
- database: str, migrations: Optional[list[str]] = migrations, **kwargs
+ database: str, migrations: Optional[list[str]] = migrations, **kwargs: Any
) -> Iterator[sqlite3.Connection]:
"""Return a context manager for a SQLite database connection. Upon entry,
open a connection, enable foreign keys, migrate if necessary, and return
diff --git a/paste/types.py b/paste/types.py
index 0170c17..69d9a21 100644
--- a/paste/types.py
+++ b/paste/types.py
@@ -13,7 +13,7 @@ class StartResponse(Protocol):
self,
status: str,
headers: list[tuple[str, str]],
- exc_info: Optional[tuple] = ...,
+ exc_info: Optional[tuple[Any, Any, Any]] = ...,
/,
) -> Callable[[bytes], object]:
...
diff --git a/pyproject.toml b/pyproject.toml
index 95cbdcf..e01f460 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -23,6 +23,11 @@ filterwarnings = [
"ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning"
]
+[tool.pyright]
+strict = [ "paste/*" ]
+stubPath = ""
+pythonVersion = "3.9"
+
[build-system]
requires = ["poetry-core"]