From 3930d8d12a478c34f8e338de5ac82932cace768b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 18 Apr 2022 22:19:16 +0100 Subject: [PATCH] Make several type aliases private (#7661) --- stdlib/_threading_local.pyi | 8 ++++---- stdlib/audioop.pyi | 12 ++++++------ stdlib/itertools.pyi | 8 ++++---- stdlib/sqlite3/dbapi2.pyi | 3 ++- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/stdlib/_threading_local.pyi b/stdlib/_threading_local.pyi index 04030038e..def996fba 100644 --- a/stdlib/_threading_local.pyi +++ b/stdlib/_threading_local.pyi @@ -3,14 +3,14 @@ from typing_extensions import TypeAlias from weakref import ReferenceType __all__ = ["local"] -localdict: TypeAlias = dict[Any, Any] +_localdict: TypeAlias = dict[Any, Any] class _localimpl: key: str - dicts: dict[int, tuple[ReferenceType[Any], localdict]] + dicts: dict[int, tuple[ReferenceType[Any], _localdict]] def __init__(self) -> None: ... - def get_dict(self) -> localdict: ... - def create_dict(self) -> localdict: ... + def get_dict(self) -> _localdict: ... + def create_dict(self) -> _localdict: ... class local: def __getattribute__(self, name: str) -> Any: ... diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 9df7b22a7..62b54ced9 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,12 +1,12 @@ from typing_extensions import TypeAlias -AdpcmState: TypeAlias = tuple[int, int] -RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]] +_AdpcmState: TypeAlias = tuple[int, int] +_RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]] class error(Exception): ... def add(__fragment1: bytes, __fragment2: bytes, __width: int) -> bytes: ... -def adpcm2lin(__fragment: bytes, __width: int, __state: AdpcmState | None) -> tuple[bytes, AdpcmState]: ... +def adpcm2lin(__fragment: bytes, __width: int, __state: _AdpcmState | None) -> tuple[bytes, _AdpcmState]: ... def alaw2lin(__fragment: bytes, __width: int) -> bytes: ... def avg(__fragment: bytes, __width: int) -> int: ... def avgpp(__fragment: bytes, __width: int) -> int: ... @@ -17,7 +17,7 @@ def findfactor(__fragment: bytes, __reference: bytes) -> float: ... def findfit(__fragment: bytes, __reference: bytes) -> tuple[int, float]: ... def findmax(__fragment: bytes, __length: int) -> int: ... def getsample(__fragment: bytes, __width: int, __index: int) -> int: ... -def lin2adpcm(__fragment: bytes, __width: int, __state: AdpcmState | None) -> tuple[bytes, AdpcmState]: ... +def lin2adpcm(__fragment: bytes, __width: int, __state: _AdpcmState | None) -> tuple[bytes, _AdpcmState]: ... def lin2alaw(__fragment: bytes, __width: int) -> bytes: ... def lin2lin(__fragment: bytes, __width: int, __newwidth: int) -> bytes: ... def lin2ulaw(__fragment: bytes, __width: int) -> bytes: ... @@ -31,10 +31,10 @@ def ratecv( __nchannels: int, __inrate: int, __outrate: int, - __state: RatecvState | None, + __state: _RatecvState | None, __weightA: int = ..., __weightB: int = ..., -) -> tuple[bytes, RatecvState]: ... +) -> tuple[bytes, _RatecvState]: ... def reverse(__fragment: bytes, __width: int) -> bytes: ... def rms(__fragment: bytes, __width: int) -> int: ... def tomono(__fragment: bytes, __width: int, __lfactor: float, __rfactor: float) -> bytes: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 3648d0ce4..43a0e8038 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -20,7 +20,7 @@ _T6 = TypeVar("_T6") _Step: TypeAlias = int | float | SupportsFloat | SupportsInt | SupportsIndex | SupportsComplex -Predicate: TypeAlias = Callable[[_T], object] +_Predicate: TypeAlias = Callable[[_T], object] # Technically count can take anything that implements a number protocol and has an add method # but we can't enforce the add method @@ -76,12 +76,12 @@ class compress(Iterator[_T], Generic[_T]): def __next__(self) -> _T: ... class dropwhile(Iterator[_T], Generic[_T]): - def __init__(self, __predicate: Predicate[_T], __iterable: Iterable[_T]) -> None: ... + def __init__(self, __predicate: _Predicate[_T], __iterable: Iterable[_T]) -> None: ... def __iter__(self: Self) -> Self: ... def __next__(self) -> _T: ... class filterfalse(Iterator[_T], Generic[_T]): - def __init__(self, __predicate: Predicate[_T] | None, __iterable: Iterable[_T]) -> None: ... + def __init__(self, __predicate: _Predicate[_T] | None, __iterable: Iterable[_T]) -> None: ... def __iter__(self: Self) -> Self: ... def __next__(self) -> _T: ... @@ -107,7 +107,7 @@ class starmap(Iterator[_T], Generic[_T]): def __next__(self) -> _T: ... class takewhile(Iterator[_T], Generic[_T]): - def __init__(self, __predicate: Predicate[_T], __iterable: Iterable[_T]) -> None: ... + def __init__(self, __predicate: _Predicate[_T], __iterable: Iterable[_T]) -> None: ... def __iter__(self: Self) -> Self: ... def __next__(self) -> _T: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 849fcb082..87e843c5f 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -410,7 +410,8 @@ class InternalError(DatabaseError): ... class NotSupportedError(DatabaseError): ... class OperationalError(DatabaseError): ... -OptimizedUnicode = str +if sys.version_info < (3, 10): + OptimizedUnicode = str @final class PrepareProtocol: