Skip to content

Make several type aliases private #7661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/_threading_local.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
12 changes: 6 additions & 6 deletions stdlib/audioop.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand All @@ -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: ...
Expand All @@ -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: ...
Expand Down
8 changes: 4 additions & 4 deletions stdlib/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ...

Expand All @@ -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: ...

Expand Down
3 changes: 2 additions & 1 deletion stdlib/sqlite3/dbapi2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ class InternalError(DatabaseError): ...
class NotSupportedError(DatabaseError): ...
class OperationalError(DatabaseError): ...

OptimizedUnicode = str
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't seem to exist at runtime or be used in the stub

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'd just figured it out from the mypy failures :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure whether it's better to do

OptimizedUnicode = str

or

OptimizedUnicode: TypeAlias = str

or

from builtins import str as OptimizedUnicode

Thoughts?

if sys.version_info < (3, 10):
OptimizedUnicode = str

@final
class PrepareProtocol:
Expand Down