Reduce use of deprecated typing aliases (#6358)

This commit is contained in:
Alex Waygood
2021-11-23 09:56:43 +00:00
committed by GitHub
parent 7e836db2f3
commit c685c2d6c6
19 changed files with 64 additions and 61 deletions

View File

@@ -1,17 +1,17 @@
from socket import socket
from typing import Any, FrozenSet, Iterable, Sequence, Set
from typing import Any, Iterable, Sequence
from .compat import HAS_IPV6 as HAS_IPV6, PY2 as PY2, WIN as WIN, string_types as string_types
from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS
truthy: FrozenSet[Any]
KNOWN_PROXY_HEADERS: FrozenSet[Any]
truthy: frozenset[Any]
KNOWN_PROXY_HEADERS: frozenset[Any]
def asbool(s: bool | str | int | None) -> bool: ...
def asoctal(s: str) -> int: ...
def aslist_cronly(value: str) -> list[str]: ...
def aslist(value: str) -> list[str]: ...
def asset(value: str | None) -> Set[str]: ...
def asset(value: str | None) -> set[str]: ...
def slash_fixed_str(s: str | None) -> str: ...
def str_iftruthy(s: str | None) -> str | None: ...
def as_socket_list(sockets: Sequence[object]) -> list[socket]: ...
@@ -27,7 +27,7 @@ class Adjustments:
threads: int = ...
trusted_proxy: str | None = ...
trusted_proxy_count: int | None = ...
trusted_proxy_headers: Set[str] = ...
trusted_proxy_headers: set[str] = ...
log_untrusted_proxy_headers: bool = ...
clear_untrusted_proxy_headers: _bool_marker | bool = ...
url_scheme: str = ...

View File

@@ -1,5 +1,5 @@
from logging import Logger
from typing import Any, Callable, Mapping, NamedTuple, Sequence, Set
from typing import Any, Callable, Mapping, NamedTuple, Sequence
from .utilities import BadRequest as BadRequest
@@ -21,14 +21,14 @@ def proxy_headers_middleware(
app: Any,
trusted_proxy: str | None = ...,
trusted_proxy_count: int = ...,
trusted_proxy_headers: Set[str] | None = ...,
trusted_proxy_headers: set[str] | None = ...,
clear_untrusted: bool = ...,
log_untrusted: bool = ...,
logger: Logger = ...,
) -> Callable[..., Any]: ...
def parse_proxy_headers(
environ: Mapping[str, str], trusted_proxy_count: int, trusted_proxy_headers: Set[str], logger: Logger = ...
) -> Set[str]: ...
environ: Mapping[str, str], trusted_proxy_count: int, trusted_proxy_headers: set[str], logger: Logger = ...
) -> set[str]: ...
def strip_brackets(addr: str) -> str: ...
def clear_untrusted_headers(
environ: Mapping[str, str], untrusted_headers: Sequence[str], log_warning: bool = ..., logger: Logger = ...

View File

@@ -1,6 +1,7 @@
from collections import deque
from logging import Logger
from threading import Condition, Lock
from typing import Any, Deque, Mapping, Sequence
from typing import Any, Mapping, Sequence
from .channel import HTTPChannel
from .utilities import Error
@@ -14,7 +15,7 @@ class ThreadedTaskDispatcher:
logger: Logger = ...
queue_logger: Logger = ...
threads: set[Any] = ...
queue: Deque[Task] = ...
queue: deque[Task] = ...
lock: Lock = ...
queue_cv: Condition = ...
thread_exit_cv: Condition = ...