Skip to content

Commit

Permalink
Stdlib: correct many parameter names (#9815)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Mar 4, 2023
1 parent 4b755c7 commit 257e287
Show file tree
Hide file tree
Showing 30 changed files with 384 additions and 355 deletions.
12 changes: 6 additions & 6 deletions stdlib/_tkinter.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class Tcl_Obj:
@property
def typename(self) -> str: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __eq__(self, __other): ...
def __ge__(self, __other): ...
def __gt__(self, __other): ...
def __le__(self, __other): ...
def __lt__(self, __other): ...
def __ne__(self, __other): ...
def __eq__(self, __value): ...
def __ge__(self, __value): ...
def __gt__(self, __value): ...
def __le__(self, __value): ...
def __lt__(self, __value): ...
def __ne__(self, __value): ...

class TclError(Exception): ...

Expand Down
28 changes: 14 additions & 14 deletions stdlib/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ class array(MutableSequence[_T], Generic[_T]):

def __len__(self) -> int: ...
@overload
def __getitem__(self, __i: SupportsIndex) -> _T: ...
def __getitem__(self, __key: SupportsIndex) -> _T: ...
@overload
def __getitem__(self, __s: slice) -> array[_T]: ...
def __getitem__(self, __key: slice) -> array[_T]: ...
@overload # type: ignore[override]
def __setitem__(self, __i: SupportsIndex, __o: _T) -> None: ...
def __setitem__(self, __key: SupportsIndex, __value: _T) -> None: ...
@overload
def __setitem__(self, __s: slice, __o: array[_T]) -> None: ...
def __delitem__(self, __i: SupportsIndex | slice) -> None: ...
def __add__(self, __x: array[_T]) -> array[_T]: ...
def __ge__(self, __other: array[_T]) -> bool: ...
def __gt__(self, __other: array[_T]) -> bool: ...
def __iadd__(self, __x: array[_T]) -> Self: ... # type: ignore[override]
def __imul__(self, __n: int) -> Self: ...
def __le__(self, __other: array[_T]) -> bool: ...
def __lt__(self, __other: array[_T]) -> bool: ...
def __mul__(self, __n: int) -> array[_T]: ...
def __rmul__(self, __n: int) -> array[_T]: ...
def __setitem__(self, __key: slice, __value: array[_T]) -> None: ...
def __delitem__(self, __key: SupportsIndex | slice) -> None: ...
def __add__(self, __value: array[_T]) -> array[_T]: ...
def __ge__(self, __value: array[_T]) -> bool: ...
def __gt__(self, __value: array[_T]) -> bool: ...
def __iadd__(self, __value: array[_T]) -> Self: ... # type: ignore[override]
def __imul__(self, __value: int) -> Self: ...
def __le__(self, __value: array[_T]) -> bool: ...
def __lt__(self, __value: array[_T]) -> bool: ...
def __mul__(self, __value: int) -> array[_T]: ...
def __rmul__(self, __value: int) -> array[_T]: ...
def __copy__(self) -> array[_T]: ...
def __deepcopy__(self, __unused: Any) -> array[_T]: ...

Expand Down
410 changes: 205 additions & 205 deletions stdlib/builtins.pyi

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,19 @@ class deque(MutableSequence[_T], Generic[_T]):
def __copy__(self) -> Self: ...
def __len__(self) -> int: ...
# These methods of deque don't take slices, unlike MutableSequence, hence the type: ignores
def __getitem__(self, __index: SupportsIndex) -> _T: ... # type: ignore[override]
def __setitem__(self, __i: SupportsIndex, __x: _T) -> None: ... # type: ignore[override]
def __delitem__(self, __i: SupportsIndex) -> None: ... # type: ignore[override]
def __contains__(self, __o: object) -> bool: ...
def __getitem__(self, __key: SupportsIndex) -> _T: ... # type: ignore[override]
def __setitem__(self, __key: SupportsIndex, __value: _T) -> None: ... # type: ignore[override]
def __delitem__(self, __key: SupportsIndex) -> None: ... # type: ignore[override]
def __contains__(self, __key: object) -> bool: ...
def __reduce__(self) -> tuple[type[Self], tuple[()], None, Iterator[_T]]: ...
def __iadd__(self, __iterable: Iterable[_T]) -> Self: ...
def __add__(self, __other: Self) -> Self: ...
def __mul__(self, __other: int) -> Self: ...
def __imul__(self, __other: int) -> Self: ...
def __lt__(self, __other: deque[_T]) -> bool: ...
def __le__(self, __other: deque[_T]) -> bool: ...
def __gt__(self, __other: deque[_T]) -> bool: ...
def __ge__(self, __other: deque[_T]) -> bool: ...
def __iadd__(self, __value: Iterable[_T]) -> Self: ...
def __add__(self, __value: Self) -> Self: ...
def __mul__(self, __value: int) -> Self: ...
def __imul__(self, __value: int) -> Self: ...
def __lt__(self, __value: deque[_T]) -> bool: ...
def __le__(self, __value: deque[_T]) -> bool: ...
def __gt__(self, __value: deque[_T]) -> bool: ...
def __ge__(self, __value: deque[_T]) -> bool: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...

Expand Down
11 changes: 8 additions & 3 deletions stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ class _GeneratorContextManager(AbstractContextManager[_T_co], ContextDecorator,
func: Callable[..., Generator[_T_co, Any, Any]]
args: tuple[Any, ...]
kwds: dict[str, Any]
def __exit__(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
if sys.version_info >= (3, 9):
def __exit__(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
else:
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...

def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ...

Expand Down
9 changes: 7 additions & 2 deletions stdlib/contextvars.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ class ContextVar(Generic[_T]):
def name(self) -> str: ...
@overload
def get(self) -> _T: ...
@overload
def get(self, default: _D | _T) -> _D | _T: ...
if sys.version_info >= (3, 8):
@overload
def get(self, default: _D | _T) -> _D | _T: ...
else:
@overload
def get(self, __default: _D | _T) -> _D | _T: ...

def set(self, __value: _T) -> Token[_T]: ...
def reset(self, __token: Token[_T]) -> None: ...
if sys.version_info >= (3, 9):
Expand Down
14 changes: 7 additions & 7 deletions stdlib/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ class _Pointer(Generic[_CT], _PointerLike, _CData):
@overload
def __init__(self, arg: _CT) -> None: ...
@overload
def __getitem__(self, __i: int) -> Any: ...
def __getitem__(self, __key: int) -> Any: ...
@overload
def __getitem__(self, __s: slice) -> list[Any]: ...
def __setitem__(self, __i: int, __o: Any) -> None: ...
def __getitem__(self, __key: slice) -> list[Any]: ...
def __setitem__(self, __key: int, __value: Any) -> None: ...

def pointer(__arg: _CT) -> _Pointer[_CT]: ...
def resize(obj: _CData, size: int) -> None: ...
Expand Down Expand Up @@ -291,13 +291,13 @@ class Array(Generic[_CT], _CData):
# the array element type would belong are annotated with Any instead.
def __init__(self, *args: Any) -> None: ...
@overload
def __getitem__(self, __i: int) -> Any: ...
def __getitem__(self, __key: int) -> Any: ...
@overload
def __getitem__(self, __s: slice) -> list[Any]: ...
def __getitem__(self, __key: slice) -> list[Any]: ...
@overload
def __setitem__(self, __i: int, __o: Any) -> None: ...
def __setitem__(self, __key: int, __value: Any) -> None: ...
@overload
def __setitem__(self, __s: slice, __o: Iterable[Any]) -> None: ...
def __setitem__(self, __key: slice, __value: Iterable[Any]) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
# Can't inherit from Sized because the metaclass conflict between
# Sized and _CData prevents using _CDataMeta.
Expand Down
88 changes: 44 additions & 44 deletions stdlib/datetime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,29 @@ class date:
def timetuple(self) -> struct_time: ...
def toordinal(self) -> int: ...
def replace(self, year: int = ..., month: int = ..., day: int = ...) -> Self: ...
def __le__(self, __other: date) -> bool: ...
def __lt__(self, __other: date) -> bool: ...
def __ge__(self, __other: date) -> bool: ...
def __gt__(self, __other: date) -> bool: ...
def __le__(self, __value: date) -> bool: ...
def __lt__(self, __value: date) -> bool: ...
def __ge__(self, __value: date) -> bool: ...
def __gt__(self, __value: date) -> bool: ...
if sys.version_info >= (3, 8):
def __add__(self, __other: timedelta) -> Self: ...
def __radd__(self, __other: timedelta) -> Self: ...
def __add__(self, __value: timedelta) -> Self: ...
def __radd__(self, __value: timedelta) -> Self: ...
@overload
def __sub__(self, __other: timedelta) -> Self: ...
def __sub__(self, __value: timedelta) -> Self: ...
@overload
def __sub__(self, __other: datetime) -> NoReturn: ...
def __sub__(self, __value: datetime) -> NoReturn: ...
@overload
def __sub__(self: _D, __other: _D) -> timedelta: ...
def __sub__(self: _D, __value: _D) -> timedelta: ...
else:
# Prior to Python 3.8, arithmetic operations always returned `date`, even in subclasses
def __add__(self, __other: timedelta) -> date: ...
def __radd__(self, __other: timedelta) -> date: ...
def __add__(self, __value: timedelta) -> date: ...
def __radd__(self, __value: timedelta) -> date: ...
@overload
def __sub__(self, __other: timedelta) -> date: ...
def __sub__(self, __value: timedelta) -> date: ...
@overload
def __sub__(self, __other: datetime) -> NoReturn: ...
def __sub__(self, __value: datetime) -> NoReturn: ...
@overload
def __sub__(self, __other: date) -> timedelta: ...
def __sub__(self, __value: date) -> timedelta: ...

def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
Expand Down Expand Up @@ -139,10 +139,10 @@ class time:
def tzinfo(self) -> _TzInfo | None: ...
@property
def fold(self) -> int: ...
def __le__(self, __other: time) -> bool: ...
def __lt__(self, __other: time) -> bool: ...
def __ge__(self, __other: time) -> bool: ...
def __gt__(self, __other: time) -> bool: ...
def __le__(self, __value: time) -> bool: ...
def __lt__(self, __value: time) -> bool: ...
def __ge__(self, __value: time) -> bool: ...
def __gt__(self, __value: time) -> bool: ...
def isoformat(self, timespec: str = ...) -> str: ...
@classmethod
def fromisoformat(cls, __time_string: str) -> Self: ...
Expand Down Expand Up @@ -193,29 +193,29 @@ class timedelta:
@property
def microseconds(self) -> int: ...
def total_seconds(self) -> float: ...
def __add__(self, __other: timedelta) -> timedelta: ...
def __radd__(self, __other: timedelta) -> timedelta: ...
def __sub__(self, __other: timedelta) -> timedelta: ...
def __rsub__(self, __other: timedelta) -> timedelta: ...
def __add__(self, __value: timedelta) -> timedelta: ...
def __radd__(self, __value: timedelta) -> timedelta: ...
def __sub__(self, __value: timedelta) -> timedelta: ...
def __rsub__(self, __value: timedelta) -> timedelta: ...
def __neg__(self) -> timedelta: ...
def __pos__(self) -> timedelta: ...
def __abs__(self) -> timedelta: ...
def __mul__(self, __other: float) -> timedelta: ...
def __rmul__(self, __other: float) -> timedelta: ...
def __mul__(self, __value: float) -> timedelta: ...
def __rmul__(self, __value: float) -> timedelta: ...
@overload
def __floordiv__(self, __other: timedelta) -> int: ...
def __floordiv__(self, __value: timedelta) -> int: ...
@overload
def __floordiv__(self, __other: int) -> timedelta: ...
def __floordiv__(self, __value: int) -> timedelta: ...
@overload
def __truediv__(self, __other: timedelta) -> float: ...
def __truediv__(self, __value: timedelta) -> float: ...
@overload
def __truediv__(self, __other: float) -> timedelta: ...
def __mod__(self, __other: timedelta) -> timedelta: ...
def __divmod__(self, __other: timedelta) -> tuple[int, timedelta]: ...
def __le__(self, __other: timedelta) -> bool: ...
def __lt__(self, __other: timedelta) -> bool: ...
def __ge__(self, __other: timedelta) -> bool: ...
def __gt__(self, __other: timedelta) -> bool: ...
def __truediv__(self, __value: float) -> timedelta: ...
def __mod__(self, __value: timedelta) -> timedelta: ...
def __divmod__(self, __value: timedelta) -> tuple[int, timedelta]: ...
def __le__(self, __value: timedelta) -> bool: ...
def __lt__(self, __value: timedelta) -> bool: ...
def __ge__(self, __value: timedelta) -> bool: ...
def __gt__(self, __value: timedelta) -> bool: ...
def __bool__(self) -> bool: ...

class datetime(date):
Expand Down Expand Up @@ -302,20 +302,20 @@ class datetime(date):
def utcoffset(self) -> timedelta | None: ...
def tzname(self) -> str | None: ...
def dst(self) -> timedelta | None: ...
def __le__(self, __other: datetime) -> bool: ... # type: ignore[override]
def __lt__(self, __other: datetime) -> bool: ... # type: ignore[override]
def __ge__(self, __other: datetime) -> bool: ... # type: ignore[override]
def __gt__(self, __other: datetime) -> bool: ... # type: ignore[override]
def __le__(self, __value: datetime) -> bool: ... # type: ignore[override]
def __lt__(self, __value: datetime) -> bool: ... # type: ignore[override]
def __ge__(self, __value: datetime) -> bool: ... # type: ignore[override]
def __gt__(self, __value: datetime) -> bool: ... # type: ignore[override]
if sys.version_info >= (3, 8):
@overload # type: ignore[override]
def __sub__(self, __other: timedelta) -> Self: ...
def __sub__(self, __value: timedelta) -> Self: ...
@overload
def __sub__(self: _D, __other: _D) -> timedelta: ...
def __sub__(self: _D, __value: _D) -> timedelta: ...
else:
# Prior to Python 3.8, arithmetic operations always returned `datetime`, even in subclasses
def __add__(self, __other: timedelta) -> datetime: ...
def __radd__(self, __other: timedelta) -> datetime: ...
def __add__(self, __value: timedelta) -> datetime: ...
def __radd__(self, __value: timedelta) -> datetime: ...
@overload # type: ignore[override]
def __sub__(self, __other: datetime) -> timedelta: ...
def __sub__(self, __value: datetime) -> timedelta: ...
@overload
def __sub__(self, __other: timedelta) -> datetime: ...
def __sub__(self, __value: timedelta) -> datetime: ...
2 changes: 1 addition & 1 deletion stdlib/email/charset.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Charset:
def header_encode_lines(self, string: str, maxlengths: Iterator[int]) -> list[str]: ...
def body_encode(self, string: str) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, __other: object) -> bool: ...
def __ne__(self, __value: object) -> bool: ...

def add_charset(
charset: str, header_enc: int | None = None, body_enc: int | None = None, output_charset: str | None = None
Expand Down
2 changes: 1 addition & 1 deletion stdlib/email/header.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Header:
def append(self, s: bytes | bytearray | str, charset: Charset | str | None = None, errors: str = "strict") -> None: ...
def encode(self, splitchars: str = ";, \t", maxlinelen: int | None = None, linesep: str = "\n") -> str: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, __other: object) -> bool: ...
def __ne__(self, __value: object) -> bool: ...

# decode_header() either returns list[tuple[str, None]] if the header
# contains no encoded parts, or list[tuple[bytes, str | None]] if the header
Expand Down
10 changes: 9 additions & 1 deletion stdlib/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ class EnumMeta(ABCMeta):

def __iter__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
def __reversed__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
def __contains__(self: type[Any], obj: object) -> bool: ...
if sys.version_info >= (3, 12):
def __contains__(self: type[Any], value: object) -> bool: ...
elif sys.version_info >= (3, 11):
def __contains__(self: type[Any], member: object) -> bool: ...
elif sys.version_info >= (3, 10):
def __contains__(self: type[Any], obj: object) -> bool: ...
else:
def __contains__(self: type[Any], member: object) -> bool: ...

def __getitem__(self: type[_EnumMemberT], name: str) -> _EnumMemberT: ...
@_builtins_property
def __members__(self: type[_EnumMemberT]) -> types.MappingProxyType[str, _EnumMemberT]: ...
Expand Down
27 changes: 19 additions & 8 deletions stdlib/fractions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,25 @@ class Fraction(Rational):
def __rmod__(b, a: int | Fraction) -> Fraction: ...
@overload
def __rmod__(b, a: float) -> float: ...
@overload
def __divmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __divmod__(a, b: float) -> tuple[float, Fraction]: ...
@overload
def __rdivmod__(b, a: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __rdivmod__(b, a: float) -> tuple[float, Fraction]: ...
if sys.version_info >= (3, 8):
@overload
def __divmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __divmod__(a, b: float) -> tuple[float, Fraction]: ...
@overload
def __rdivmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __rdivmod__(a, b: float) -> tuple[float, Fraction]: ...
else:
@overload
def __divmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __divmod__(self, other: float) -> tuple[float, Fraction]: ...
@overload
def __rdivmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __rdivmod__(self, other: float) -> tuple[float, Fraction]: ...

@overload
def __pow__(a, b: int) -> Fraction: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion stdlib/heapq.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def merge(
) -> Iterable[_S]: ...
def nlargest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = None) -> list[_S]: ...
def nsmallest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = None) -> list[_S]: ...
def _heapify_max(__x: list[Any]) -> None: ... # undocumented
def _heapify_max(__heap: list[Any]) -> None: ... # undocumented
4 changes: 3 additions & 1 deletion stdlib/ipaddress.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class _BaseAddress(_IPAddressBase, SupportsInt):
def __add__(self, other: int) -> Self: ...
def __int__(self) -> int: ...
def __sub__(self, other: int) -> Self: ...
def __format__(self, fmt: str) -> str: ...
if sys.version_info >= (3, 9):
def __format__(self, fmt: str) -> str: ...

def __eq__(self, other: object) -> bool: ...
def __lt__(self, other: Self) -> bool: ...
if sys.version_info >= (3, 11):
Expand Down
10 changes: 5 additions & 5 deletions stdlib/mmap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class mmap(Iterable[int], Sized):
def read(self, n: int | None = ...) -> bytes: ...
def write(self, bytes: ReadableBuffer) -> int: ...
@overload
def __getitem__(self, __index: int) -> int: ...
def __getitem__(self, __key: int) -> int: ...
@overload
def __getitem__(self, __index: slice) -> bytes: ...
def __delitem__(self, __index: int | slice) -> NoReturn: ...
def __getitem__(self, __key: slice) -> bytes: ...
def __delitem__(self, __key: int | slice) -> NoReturn: ...
@overload
def __setitem__(self, __index: int, __object: int) -> None: ...
def __setitem__(self, __key: int, __value: int) -> None: ...
@overload
def __setitem__(self, __index: slice, __object: ReadableBuffer) -> None: ...
def __setitem__(self, __key: slice, __value: ReadableBuffer) -> None: ...
# Doesn't actually exist, but the object actually supports "in" because it has __getitem__,
# so we claim that there is also a __contains__ to help type checkers.
def __contains__(self, __o: object) -> bool: ...
Expand Down
Loading

0 comments on commit 257e287

Please sign in to comment.