Skip to content
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

Sync typeshed #14598

Merged
merged 4 commits into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
1 change: 0 additions & 1 deletion mypy/typeshed/LICENSE
Original file line number Diff line number Diff line change
@@ -235,4 +235,3 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

= = = = =

40 changes: 20 additions & 20 deletions mypy/typeshed/stdlib/_bisect.pyi
Original file line number Diff line number Diff line change
@@ -8,67 +8,67 @@ _T = TypeVar("_T")
if sys.version_info >= (3, 10):
@overload
def bisect_left(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ..., *, key: None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None, *, key: None = None
) -> int: ...
@overload
def bisect_left(
a: Sequence[_T],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: Callable[[_T], SupportsRichComparisonT] = ...,
key: Callable[[_T], SupportsRichComparisonT],
) -> int: ...
@overload
def bisect_right(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ..., *, key: None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None, *, key: None = None
) -> int: ...
@overload
def bisect_right(
a: Sequence[_T],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: Callable[[_T], SupportsRichComparisonT] = ...,
key: Callable[[_T], SupportsRichComparisonT],
) -> int: ...
@overload
def insort_left(
a: MutableSequence[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: None = ...,
key: None = None,
) -> None: ...
@overload
def insort_left(
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsRichComparisonT] = ...
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
) -> None: ...
@overload
def insort_right(
a: MutableSequence[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = ...,
hi: int | None = ...,
lo: int = 0,
hi: int | None = None,
*,
key: None = ...,
key: None = None,
) -> None: ...
@overload
def insort_right(
a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsRichComparisonT] = ...
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
) -> None: ...

else:
def bisect_left(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> int: ...
def bisect_right(
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: Sequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> int: ...
def insort_left(
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> None: ...
def insort_right(
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = ..., hi: int | None = ...
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
) -> None: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_bootlocale.pyi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
def getpreferredencoding(do_setlocale: bool = ...) -> str: ...
def getpreferredencoding(do_setlocale: bool = True) -> str: ...
100 changes: 51 additions & 49 deletions mypy/typeshed/stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -45,92 +45,94 @@ _BytesToBytesEncoding: TypeAlias = Literal[
_StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]

@overload
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ...
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ...
@overload
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = ...) -> str: ... # type: ignore[misc]
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[misc]
@overload
def encode(obj: str, encoding: str = ..., errors: str = ...) -> bytes: ...
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ... # type: ignore[misc]
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[misc]
@overload
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = ...) -> str: ...
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ...

# these are documented as text encodings but in practice they also accept str as input
@overload
def decode(
obj: str, encoding: Literal["unicode_escape", "unicode-escape", "raw_unicode_escape", "raw-unicode-escape"], errors: str = ...
obj: str,
encoding: Literal["unicode_escape", "unicode-escape", "raw_unicode_escape", "raw-unicode-escape"],
errors: str = "strict",
) -> str: ...

# hex is officially documented as a bytes to bytes encoding, but it appears to also work with str
@overload
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = ...) -> bytes: ...
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: str = ..., errors: str = ...) -> str: ...
def decode(obj: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> str: ...
def lookup(__encoding: str) -> codecs.CodecInfo: ...
def charmap_build(__map: str) -> _CharMap: ...
def ascii_decode(__data: ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def charmap_decode(__data: ReadableBuffer, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[bytes, int]: ...
def escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = ...) -> tuple[bytes, int]: ...
def latin_1_decode(__data: ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def ascii_decode(__data: ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def charmap_decode(__data: ReadableBuffer, __errors: str | None = None, __mapping: _CharMap | None = None) -> tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = None, __mapping: _CharMap | None = None) -> tuple[bytes, int]: ...
def escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = None) -> tuple[bytes, int]: ...
def latin_1_decode(__data: ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info >= (3, 9):
def raw_unicode_escape_decode(
__data: str | ReadableBuffer, __errors: str | None = ..., __final: bool = ...
__data: str | ReadableBuffer, __errors: str | None = None, __final: bool = True
) -> tuple[str, int]: ...

else:
def raw_unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def raw_unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...

def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def readbuffer_encode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[bytes, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def readbuffer_encode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info >= (3, 9):
def unicode_escape_decode(
__data: str | ReadableBuffer, __errors: str | None = ..., __final: bool = ...
__data: str | ReadableBuffer, __errors: str | None = None, __final: bool = True
) -> tuple[str, int]: ...

else:
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...

def unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.version_info < (3, 8):
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = ...) -> tuple[bytes, int]: ...
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...

def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: str | None = None, __byteorder: int = 0) -> tuple[bytes, int]: ...
def utf_16_ex_decode(
__data: ReadableBuffer, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
__data: ReadableBuffer, __errors: str | None = None, __byteorder: int = 0, __final: int = False
) -> tuple[str, int, int]: ...
def utf_16_le_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_be_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_16_le_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_32_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_32_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = None, __byteorder: int = 0) -> tuple[bytes, int]: ...
def utf_32_ex_decode(
__data: ReadableBuffer, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
__data: ReadableBuffer, __errors: str | None = None, __byteorder: int = 0, __final: int = False
) -> tuple[str, int, int]: ...
def utf_32_le_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_7_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_8_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_le_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_7_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def utf_8_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...

if sys.platform == "win32":
def mbcs_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def mbcs_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def code_page_decode(
__codepage: int, __data: ReadableBuffer, __errors: str | None = ..., __final: int = ...
__codepage: int, __data: ReadableBuffer, __errors: str | None = None, __final: int = False
) -> tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def oem_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
def oem_decode(__data: ReadableBuffer, __errors: str | None = None, __final: int = False) -> tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from types import MappingProxyType
from typing import ( # noqa: Y027,Y038
from typing import ( # noqa: Y022,Y038
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_compression.pyi
Original file line number Diff line number Diff line change
@@ -21,5 +21,5 @@ class DecompressReader(RawIOBase):
**decomp_args: Any,
) -> None: ...
def readinto(self, b: WriteableBuffer) -> int: ...
def read(self, size: int = ...) -> bytes: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def read(self, size: int = -1) -> bytes: ...
def seek(self, offset: int, whence: int = 0) -> int: ...
30 changes: 15 additions & 15 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ if sys.platform != "win32":
def baudrate() -> int: ...
def beep() -> None: ...
def can_change_color() -> bool: ...
def cbreak(__flag: bool = ...) -> None: ...
def cbreak(__flag: bool = True) -> None: ...
def color_content(__color_number: int) -> tuple[int, int, int]: ...
# Changed in Python 3.8.8 and 3.9.2
if sys.version_info >= (3, 8):
@@ -287,7 +287,7 @@ if sys.platform != "win32":
def def_shell_mode() -> None: ...
def delay_output(__ms: int) -> None: ...
def doupdate() -> None: ...
def echo(__flag: bool = ...) -> None: ...
def echo(__flag: bool = True) -> None: ...
def endwin() -> None: ...
def erasechar() -> bytes: ...
def filter() -> None: ...
@@ -323,7 +323,7 @@ if sys.platform != "win32":
def napms(__ms: int) -> int: ...
def newpad(__nlines: int, __ncols: int) -> _CursesWindow: ...
def newwin(__nlines: int, __ncols: int, __begin_y: int = ..., __begin_x: int = ...) -> _CursesWindow: ...
def nl(__flag: bool = ...) -> None: ...
def nl(__flag: bool = True) -> None: ...
def nocbreak() -> None: ...
def noecho() -> None: ...
def nonl() -> None: ...
@@ -332,8 +332,8 @@ if sys.platform != "win32":
def pair_content(__pair_number: int) -> tuple[int, int]: ...
def pair_number(__attr: int) -> int: ...
def putp(__string: ReadOnlyBuffer) -> None: ...
def qiflush(__flag: bool = ...) -> None: ...
def raw(__flag: bool = ...) -> None: ...
def qiflush(__flag: bool = True) -> None: ...
def raw(__flag: bool = True) -> None: ...
def reset_prog_mode() -> None: ...
def reset_shell_mode() -> None: ...
def resetty() -> None: ...
@@ -345,7 +345,7 @@ if sys.platform != "win32":
def set_tabsize(__size: int) -> None: ...

def setsyx(__y: int, __x: int) -> None: ...
def setupterm(term: str | None = ..., fd: int = ...) -> None: ...
def setupterm(term: str | None = None, fd: int = -1) -> None: ...
def start_color() -> None: ...
def termattrs() -> int: ...
def termname() -> bytes: ...
@@ -354,15 +354,15 @@ if sys.platform != "win32":
def tigetstr(__capname: str) -> bytes | None: ...
def tparm(
__str: ReadOnlyBuffer,
__i1: int = ...,
__i2: int = ...,
__i3: int = ...,
__i4: int = ...,
__i5: int = ...,
__i6: int = ...,
__i7: int = ...,
__i8: int = ...,
__i9: int = ...,
__i1: int = 0,
__i2: int = 0,
__i3: int = 0,
__i4: int = 0,
__i5: int = 0,
__i6: int = 0,
__i7: int = 0,
__i8: int = 0,
__i9: int = 0,
) -> bytes: ...
def typeahead(__fd: int) -> None: ...
def unctrl(__ch: _ChType) -> bytes: ...
80 changes: 40 additions & 40 deletions mypy/typeshed/stdlib/_decimal.pyi
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ def getcontext() -> Context: ...

if sys.version_info >= (3, 11):
def localcontext(
ctx: Context | None = ...,
ctx: Context | None = None,
*,
prec: int | None = ...,
rounding: str | None = ...,
@@ -66,17 +66,17 @@ if sys.version_info >= (3, 11):
) -> _ContextManager: ...

else:
def localcontext(ctx: Context | None = ...) -> _ContextManager: ...
def localcontext(ctx: Context | None = None) -> _ContextManager: ...

class Decimal:
def __new__(cls: type[Self], value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
@classmethod
def from_float(cls: type[Self], __f: float) -> Self: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def as_tuple(self) -> DecimalTuple: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def to_eng_string(self, context: Context | None = ...) -> str: ...
def to_eng_string(self, context: Context | None = None) -> str: ...
def __abs__(self) -> Decimal: ...
def __add__(self, __other: _Decimal) -> Decimal: ...
def __divmod__(self, __other: _Decimal) -> tuple[Decimal, Decimal]: ...
@@ -100,7 +100,7 @@ class Decimal:
def __rtruediv__(self, __other: _Decimal) -> Decimal: ...
def __sub__(self, __other: _Decimal) -> Decimal: ...
def __truediv__(self, __other: _Decimal) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __trunc__(self) -> int: ...
@@ -116,53 +116,53 @@ class Decimal:
def __round__(self, __ndigits: int) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = ...) -> Decimal: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
def __rpow__(self, __other: _Decimal, __context: Context | None = ...) -> Decimal: ...
def normalize(self, context: Context | None = ...) -> Decimal: ...
def quantize(self, exp: _Decimal, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Context | None = ...) -> bool: ...
def to_integral_exact(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ...
def to_integral_value(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ...
def to_integral(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ...
def sqrt(self, context: Context | None = ...) -> Decimal: ...
def max(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def min(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def normalize(self, context: Context | None = None) -> Decimal: ...
def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def sqrt(self, context: Context | None = None) -> Decimal: ...
def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def adjusted(self) -> int: ...
def canonical(self) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def compare_total(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def copy_abs(self) -> Decimal: ...
def copy_negate(self) -> Decimal: ...
def copy_sign(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def exp(self, context: Context | None = ...) -> Decimal: ...
def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def exp(self, context: Context | None = None) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
def is_infinite(self) -> bool: ...
def is_nan(self) -> bool: ...
def is_normal(self, context: Context | None = ...) -> bool: ...
def is_normal(self, context: Context | None = None) -> bool: ...
def is_qnan(self) -> bool: ...
def is_signed(self) -> bool: ...
def is_snan(self) -> bool: ...
def is_subnormal(self, context: Context | None = ...) -> bool: ...
def is_subnormal(self, context: Context | None = None) -> bool: ...
def is_zero(self) -> bool: ...
def ln(self, context: Context | None = ...) -> Decimal: ...
def log10(self, context: Context | None = ...) -> Decimal: ...
def logb(self, context: Context | None = ...) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def logical_invert(self, context: Context | None = ...) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def next_minus(self, context: Context | None = ...) -> Decimal: ...
def next_plus(self, context: Context | None = ...) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def number_class(self, context: Context | None = ...) -> str: ...
def ln(self, context: Context | None = None) -> Decimal: ...
def log10(self, context: Context | None = None) -> Decimal: ...
def logb(self, context: Context | None = None) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_invert(self, context: Context | None = None) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def next_minus(self, context: Context | None = None) -> Decimal: ...
def next_plus(self, context: Context | None = None) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def number_class(self, context: Context | None = None) -> str: ...
def radix(self) -> Decimal: ...
def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def shift(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __reduce__(self: Self) -> tuple[type[Self], tuple[str]]: ...
def __copy__(self: Self) -> Self: ...
def __deepcopy__(self: Self, __memo: Any) -> Self: ...
@@ -212,7 +212,7 @@ class Context:
__hash__: ClassVar[None] # type: ignore[assignment]
def Etiny(self) -> int: ...
def Etop(self) -> int: ...
def create_decimal(self, __num: _DecimalNew = ...) -> Decimal: ...
def create_decimal(self, __num: _DecimalNew = "0") -> Decimal: ...
def create_decimal_from_float(self, __f: float) -> Decimal: ...
def abs(self, __x: _Decimal) -> Decimal: ...
def add(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
@@ -259,7 +259,7 @@ class Context:
def normalize(self, __x: _Decimal) -> Decimal: ...
def number_class(self, __x: _Decimal) -> str: ...
def plus(self, __x: _Decimal) -> Decimal: ...
def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = ...) -> Decimal: ...
def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal: ...
def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def radix(self) -> Decimal: ...
def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_dummy_thread.pyi
Original file line number Diff line number Diff line change
@@ -11,12 +11,12 @@ def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwa
def exit() -> NoReturn: ...
def get_ident() -> int: ...
def allocate_lock() -> LockType: ...
def stack_size(size: int | None = ...) -> int: ...
def stack_size(size: int | None = None) -> int: ...

class LockType:
locked_status: bool
def acquire(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
def __enter__(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
def acquire(self, waitflag: bool | None = None, timeout: int = -1) -> bool: ...
def __enter__(self, waitflag: bool | None = None, timeout: int = -1) -> bool: ...
def __exit__(self, typ: type[BaseException] | None, val: BaseException | None, tb: TracebackType | None) -> None: ...
def release(self) -> bool: ...
def locked(self) -> bool: ...
40 changes: 20 additions & 20 deletions mypy/typeshed/stdlib/_dummy_threading.pyi
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ def enumerate() -> list[Thread]: ...
def main_thread() -> Thread: ...
def settrace(func: TraceFunction) -> None: ...
def setprofile(func: ProfileFunction | None) -> None: ...
def stack_size(size: int = ...) -> int: ...
def stack_size(size: int | None = None) -> int: ...

TIMEOUT_MAX: float

@@ -59,17 +59,17 @@ class Thread:
def ident(self) -> int | None: ...
def __init__(
self,
group: None = ...,
target: Callable[..., object] | None = ...,
name: str | None = ...,
group: None = None,
target: Callable[..., object] | None = None,
name: str | None = None,
args: Iterable[Any] = ...,
kwargs: Mapping[str, Any] | None = ...,
kwargs: Mapping[str, Any] | None = None,
*,
daemon: bool | None = ...,
daemon: bool | None = None,
) -> None: ...
def start(self) -> None: ...
def run(self) -> None: ...
def join(self, timeout: float | None = ...) -> None: ...
def join(self, timeout: float | None = None) -> None: ...
def getName(self) -> str: ...
def setName(self, name: str) -> None: ...
if sys.version_info >= (3, 8):
@@ -99,32 +99,32 @@ class _RLock:
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...

RLock = _RLock

class Condition:
def __init__(self, lock: Lock | _RLock | None = ...) -> None: ...
def __init__(self, lock: Lock | _RLock | None = None) -> None: ...
def __enter__(self) -> bool: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
def wait(self, timeout: float | None = ...) -> bool: ...
def wait_for(self, predicate: Callable[[], _T], timeout: float | None = ...) -> _T: ...
def notify(self, n: int = ...) -> None: ...
def wait(self, timeout: float | None = None) -> bool: ...
def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ...
def notify(self, n: int = 1) -> None: ...
def notify_all(self) -> None: ...
def notifyAll(self) -> None: ...

class Semaphore:
def __init__(self, value: int = ...) -> None: ...
def __init__(self, value: int = 1) -> None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ...
def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ...
def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
def __enter__(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
if sys.version_info >= (3, 9):
def release(self, n: int = ...) -> None: ...
else:
@@ -136,7 +136,7 @@ class Event:
def is_set(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
def wait(self, timeout: float | None = ...) -> bool: ...
def wait(self, timeout: float | None = None) -> bool: ...

if sys.version_info >= (3, 8):
from _thread import _excepthook, _ExceptHookArgs
@@ -149,8 +149,8 @@ class Timer(Thread):
self,
interval: float,
function: Callable[..., object],
args: Iterable[Any] | None = ...,
kwargs: Mapping[str, Any] | None = ...,
args: Iterable[Any] | None = None,
kwargs: Mapping[str, Any] | None = None,
) -> None: ...
def cancel(self) -> None: ...

@@ -161,8 +161,8 @@ class Barrier:
def n_waiting(self) -> int: ...
@property
def broken(self) -> bool: ...
def __init__(self, parties: int, action: Callable[[], None] | None = ..., timeout: float | None = ...) -> None: ...
def wait(self, timeout: float | None = ...) -> int: ...
def __init__(self, parties: int, action: Callable[[], None] | None = None, timeout: float | None = None) -> None: ...
def wait(self, timeout: float | None = None) -> int: ...
def reset(self) -> None: ...
def abort(self) -> None: ...

6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_imp.pyi
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ check_hash_based_pycs: str

def source_hash(key: int, source: ReadableBuffer) -> bytes: ...
def create_builtin(__spec: ModuleSpec) -> types.ModuleType: ...
def create_dynamic(__spec: ModuleSpec, __file: Any = ...) -> types.ModuleType: ...
def create_dynamic(__spec: ModuleSpec, __file: Any = None) -> types.ModuleType: ...
def acquire_lock() -> None: ...
def exec_builtin(__mod: types.ModuleType) -> int: ...
def exec_dynamic(__mod: types.ModuleType) -> int: ...
@@ -21,8 +21,8 @@ def lock_held() -> bool: ...
def release_lock() -> None: ...

if sys.version_info >= (3, 11):
def find_frozen(__name: str, *, withdata: bool = ...) -> tuple[memoryview | None, bool, str | None] | None: ...
def get_frozen_object(__name: str, __data: ReadableBuffer | None = ...) -> types.CodeType: ...
def find_frozen(__name: str, *, withdata: bool = False) -> tuple[memoryview | None, bool, str | None] | None: ...
def get_frozen_object(__name: str, __data: ReadableBuffer | None = None) -> types.CodeType: ...

else:
def get_frozen_object(__name: str) -> types.CodeType: ...
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_markupbase.pyi
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ class ParserBase:
def reset(self) -> None: ...
def getpos(self) -> tuple[int, int]: ...
def unknown_decl(self, data: str) -> None: ...
def parse_comment(self, i: int, report: int = ...) -> int: ... # undocumented
def parse_comment(self, i: int, report: int = 1) -> int: ... # undocumented
def parse_declaration(self, i: int) -> int: ... # undocumented
def parse_marked_section(self, i: int, report: int = ...) -> int: ... # undocumented
def parse_marked_section(self, i: int, report: int = 1) -> int: ... # undocumented
def updatepos(self, i: int, j: int) -> int: ... # undocumented
if sys.version_info < (3, 10):
# Removed from ParserBase: https://bugs.python.org/issue31844
4 changes: 3 additions & 1 deletion mypy/typeshed/stdlib/_msi.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys

if sys.platform == "win32":

# Actual typename View, not exposed by the implementation
class _View:
def Execute(self, params: _Record | None = ...) -> None: ...
@@ -12,6 +11,7 @@ if sys.platform == "win32":
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]

# Actual typename SummaryInformation, not exposed by the implementation
class _SummaryInformation:
def GetProperty(self, field: int) -> int | bytes | None: ...
@@ -21,6 +21,7 @@ if sys.platform == "win32":
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]

# Actual typename Database, not exposed by the implementation
class _Database:
def OpenView(self, sql: str) -> _View: ...
@@ -30,6 +31,7 @@ if sys.platform == "win32":
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]

# Actual typename Record, not exposed by the implementation
class _Record:
def GetFieldCount(self) -> int: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_operator.pyi
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ def setitem(__a: MutableSequence[_T], __b: SupportsIndex, __c: _T) -> None: ...
def setitem(__a: MutableSequence[_T], __b: slice, __c: Sequence[_T]) -> None: ...
@overload
def setitem(__a: MutableMapping[_K, _V], __b: _K, __c: _V) -> None: ...
def length_hint(__obj: object, __default: int = ...) -> int: ...
def length_hint(__obj: object, __default: int = 0) -> int: ...
@final
class attrgetter(Generic[_T_co]):
@overload
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ _UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented
_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
_INITPRE: str # undocumented

def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented
def _find_executable(executable: str, path: str | None = None) -> str | None: ... # undocumented

if sys.version_info >= (3, 8):
def _read_output(commandstring: str, capture_stderr: bool = ...) -> str | None: ... # undocumented
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented

else:
def _read_output(commandstring: str) -> str | None: ... # undocumented
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_random.pyi
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ _State: TypeAlias = tuple[int, ...]

class Random:
def __init__(self, seed: object = ...) -> None: ...
def seed(self, __n: object = ...) -> None: ...
def seed(self, __n: object = None) -> None: ...
def getstate(self) -> _State: ...
def setstate(self, __state: _State) -> None: ...
def random(self) -> float: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_sitebuiltins.pyi
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ class Quitter:
name: str
eof: str
def __init__(self, name: str, eof: str) -> None: ...
def __call__(self, code: int | None = ...) -> NoReturn: ...
def __call__(self, code: int | None = None) -> NoReturn: ...

class _Printer:
MAXLINES: ClassVar[Literal[23]]
38 changes: 26 additions & 12 deletions mypy/typeshed/stdlib/_tkinter.pyi
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ class TkappType:

def createtimerhandler(self, __milliseconds, __func): ...
def deletecommand(self, __name): ...
def dooneevent(self, __flags: int = ...): ...
def dooneevent(self, __flags: int = 0): ...
def eval(self, __script: str) -> str: ...
def evalfile(self, __fileName): ...
def exprboolean(self, __s): ...
@@ -76,7 +76,7 @@ class TkappType:
def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self): ...
def loadtk(self) -> None: ...
def mainloop(self, __threshold: int = ...): ...
def mainloop(self, __threshold: int = 0): ...
def quit(self): ...
def record(self, __script): ...
def setvar(self, *ags, **kwargs): ...
@@ -107,15 +107,29 @@ TK_VERSION: str
class TkttType:
def deletetimerhandler(self): ...

def create(
__screenName: str | None = ...,
__baseName: str | None = ...,
__className: str = ...,
__interactive: bool = ...,
__wantobjects: bool = ...,
__wantTk: bool = ...,
__sync: bool = ...,
__use: str | None = ...,
): ...
if sys.version_info >= (3, 8):
def create(
__screenName: str | None = None,
__baseName: str = "",
__className: str = "Tk",
__interactive: bool = False,
__wantobjects: bool = False,
__wantTk: bool = True,
__sync: bool = False,
__use: str | None = None,
): ...

else:
def create(
__screenName: str | None = None,
__baseName: str | None = None,
__className: str = "Tk",
__interactive: bool = False,
__wantobjects: bool = False,
__wantTk: bool = True,
__sync: bool = False,
__use: str | None = None,
): ...

def getbusywaitinterval(): ...
def setbusywaitinterval(__new_val): ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_tracemalloc.pyi
Original file line number Diff line number Diff line change
@@ -13,5 +13,5 @@ def is_tracing() -> bool: ...
if sys.version_info >= (3, 9):
def reset_peak() -> None: ...

def start(__nframe: int = ...) -> None: ...
def start(__nframe: int = 1) -> None: ...
def stop() -> None: ...
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_warnings.pyi
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ _onceregistry: dict[Any, Any]
filters: list[tuple[str, str | None, type[Warning], str | None, int]]

@overload
def warn(message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
def warn(message: str, category: type[Warning] | None = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
def warn(message: Warning, category: Any = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
@overload
def warn_explicit(
message: str,
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_weakref.pyi
Original file line number Diff line number Diff line change
@@ -33,6 +33,6 @@ def getweakrefs(__object: Any) -> list[Any]: ...

# Return CallableProxyType if object is callable, ProxyType otherwise
@overload
def proxy(__object: _C, __callback: Callable[[_C], Any] | None = ...) -> CallableProxyType[_C]: ...
def proxy(__object: _C, __callback: Callable[[_C], Any] | None = None) -> CallableProxyType[_C]: ...
@overload
def proxy(__object: _T, __callback: Callable[[_T], Any] | None = ...) -> Any: ...
def proxy(__object: _T, __callback: Callable[[_T], Any] | None = None) -> Any: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_weakrefset.pyi
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ _T = TypeVar("_T")

class WeakSet(MutableSet[_T], Generic[_T]):
@overload
def __init__(self, data: None = ...) -> None: ...
def __init__(self, data: None = None) -> None: ...
@overload
def __init__(self, data: Iterable[_T]) -> None: ...
def add(self, item: _T) -> None: ...
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/_winapi.pyi
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ if sys.platform == "win32":
@overload
def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: Literal[False] = ...) -> None: ...
def ConnectNamedPipe(handle: int, overlapped: Literal[False] = False) -> None: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: bool) -> Overlapped | None: ...
def CreateFile(
@@ -169,7 +169,7 @@ if sys.platform == "win32":
__target_process_handle: int,
__desired_access: int,
__inherit_handle: bool,
__options: int = ...,
__options: int = 0,
) -> int: ...
def ExitProcess(__ExitCode: int) -> NoReturn: ...
def GetACP() -> int: ...
@@ -181,28 +181,28 @@ if sys.platform == "win32":
def GetStdHandle(__std_handle: int) -> int: ...
def GetVersion() -> int: ...
def OpenProcess(__desired_access: int, __inherit_handle: bool, __process_id: int) -> int: ...
def PeekNamedPipe(__handle: int, __size: int = ...) -> tuple[int, int] | tuple[bytes, int, int]: ...
def PeekNamedPipe(__handle: int, __size: int = 0) -> tuple[int, int] | tuple[bytes, int, int]: ...
if sys.version_info >= (3, 10):
def LCMapStringEx(locale: str, flags: int, src: str) -> str: ...
def UnmapViewOfFile(__address: int) -> None: ...

@overload
def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
@overload
def ReadFile(handle: int, size: int, overlapped: Literal[False] = ...) -> tuple[bytes, int]: ...
def ReadFile(handle: int, size: int, overlapped: Literal[False] = False) -> tuple[bytes, int]: ...
@overload
def ReadFile(handle: int, size: int, overlapped: int | bool) -> tuple[Any, int]: ...
def SetNamedPipeHandleState(
__named_pipe: int, __mode: int | None, __max_collection_count: int | None, __collect_data_timeout: int | None
) -> None: ...
def TerminateProcess(__handle: int, __exit_code: int) -> None: ...
def WaitForMultipleObjects(__handle_seq: Sequence[int], __wait_flag: bool, __milliseconds: int = ...) -> int: ...
def WaitForMultipleObjects(__handle_seq: Sequence[int], __wait_flag: bool, __milliseconds: int = 4294967295) -> int: ...
def WaitForSingleObject(__handle: int, __milliseconds: int) -> int: ...
def WaitNamedPipe(__name: str, __timeout: int) -> None: ...
@overload
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
@overload
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[False] = ...) -> tuple[int, int]: ...
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[False] = False) -> tuple[int, int]: ...
@overload
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: int | bool) -> tuple[Any, int]: ...
@final
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/abc.pyi
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ class ABCMeta(type):

def __instancecheck__(cls: ABCMeta, instance: Any) -> bool: ...
def __subclasscheck__(cls: ABCMeta, subclass: type) -> bool: ...
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ...
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = None) -> None: ...
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...

def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/aifc.pyi
Original file line number Diff line number Diff line change
@@ -81,12 +81,12 @@ def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
@overload
def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def open(f: _File, mode: str | None = ...) -> Any: ...
def open(f: _File, mode: str | None = None) -> Any: ...

if sys.version_info < (3, 9):
@overload
def openfp(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
@overload
def openfp(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def openfp(f: _File, mode: str | None = ...) -> Any: ...
def openfp(f: _File, mode: str | None = None) -> Any: ...
163 changes: 85 additions & 78 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ class _ActionsContainer:
_has_negative_number_optionals: list[bool]
def __init__(self, description: str | None, prefix_chars: str, argument_default: Any, conflict_handler: str) -> None: ...
def register(self, registry_name: str, value: Any, object: Any) -> None: ...
def _registry_get(self, registry_name: str, value: Any, default: Any = ...) -> Any: ...
def _registry_get(self, registry_name: str, value: Any, default: Any = None) -> Any: ...
def set_defaults(self, **kwargs: Any) -> None: ...
def get_default(self, dest: str) -> Any: ...
def add_argument(
@@ -104,7 +104,7 @@ class _ActionsContainer:
def _add_container_actions(self, container: _ActionsContainer) -> None: ...
def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ...
def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
def _pop_action_class(self, kwargs: Any, default: type[Action] | None = ...) -> type[Action]: ...
def _pop_action_class(self, kwargs: Any, default: type[Action] | None = None) -> type[Action]: ...
def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
def _check_conflict(self, action: Action) -> None: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
@@ -131,40 +131,40 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
if sys.version_info >= (3, 9):
def __init__(
self,
prog: str | None = ...,
usage: str | None = ...,
description: str | None = ...,
epilog: str | None = ...,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = ...,
formatter_class: _FormatterClass = ...,
prefix_chars: str = ...,
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
add_help: bool = ...,
allow_abbrev: bool = ...,
exit_on_error: bool = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
exit_on_error: bool = True,
) -> None: ...
else:
def __init__(
self,
prog: str | None = ...,
usage: str | None = ...,
description: str | None = ...,
epilog: str | None = ...,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = ...,
formatter_class: _FormatterClass = ...,
prefix_chars: str = ...,
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
add_help: bool = ...,
allow_abbrev: bool = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
) -> None: ...
# The type-ignores in these overloads should be temporary. See:
# https://github.com/python/typeshed/pull/2643#issuecomment-442280277
@overload
def parse_args(self, args: Sequence[str] | None = ...) -> Namespace: ...
def parse_args(self, args: Sequence[str] | None = None) -> Namespace: ...
@overload
def parse_args(self, args: Sequence[str] | None, namespace: None) -> Namespace: ... # type: ignore[misc]
@overload
@@ -202,19 +202,19 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
help: str | None = ...,
metavar: str | None = ...,
) -> _SubParsersAction[_ArgumentParserT]: ...
def print_usage(self, file: IO[str] | None = ...) -> None: ...
def print_help(self, file: IO[str] | None = ...) -> None: ...
def print_usage(self, file: IO[str] | None = None) -> None: ...
def print_help(self, file: IO[str] | None = None) -> None: ...
def format_usage(self) -> str: ...
def format_help(self) -> str: ...
def parse_known_args(
self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...
self, args: Sequence[str] | None = None, namespace: Namespace | None = None
) -> tuple[Namespace, list[str]]: ...
def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ...
def exit(self, status: int = ..., message: str | None = ...) -> NoReturn: ...
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
def error(self, message: str) -> NoReturn: ...
def parse_intermixed_args(self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...) -> Namespace: ...
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: Namespace | None = None) -> Namespace: ...
def parse_known_intermixed_args(
self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...
self, args: Sequence[str] | None = None, namespace: Namespace | None = None
) -> tuple[Namespace, list[str]]: ...
# undocumented
def _get_optional_actions(self) -> list[Action]: ...
@@ -230,7 +230,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def _get_value(self, action: Action, arg_string: str) -> Any: ...
def _check_value(self, action: Action, value: Any) -> None: ...
def _get_formatter(self) -> HelpFormatter: ...
def _print_message(self, message: str, file: IO[str] | None = ...) -> None: ...
def _print_message(self, message: str, file: IO[str] | None = None) -> None: ...

class HelpFormatter:
# undocumented
@@ -246,15 +246,15 @@ class HelpFormatter:
_whitespace_matcher: Pattern[str]
_long_break_matcher: Pattern[str]
_Section: type[Any] # Nested class
def __init__(self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ...) -> None: ...
def __init__(self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None) -> None: ...
def _indent(self) -> None: ...
def _dedent(self) -> None: ...
def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ...
def start_section(self, heading: str | None) -> None: ...
def end_section(self) -> None: ...
def add_text(self, text: str | None) -> None: ...
def add_usage(
self, usage: str | None, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: str | None = ...
self, usage: str | None, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: str | None = None
) -> None: ...
def add_argument(self, action: Action) -> None: ...
def add_arguments(self, actions: Iterable[Action]) -> None: ...
@@ -297,17 +297,17 @@ class Action(_AttributeHolder):
self,
option_strings: Sequence[str],
dest: str,
nargs: int | str | None = ...,
const: _T | None = ...,
default: _T | str | None = ...,
type: Callable[[str], _T] | FileType | None = ...,
choices: Iterable[_T] | None = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
nargs: int | str | None = None,
const: _T | None = None,
default: _T | str | None = None,
type: Callable[[str], _T] | FileType | None = None,
choices: Iterable[_T] | None = None,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...
def __call__(
self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = ...
self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = None
) -> None: ...
if sys.version_info >= (3, 9):
def format_usage(self) -> str: ...
@@ -318,12 +318,12 @@ if sys.version_info >= (3, 9):
self,
option_strings: Sequence[str],
dest: str,
default: _T | str | None = ...,
type: Callable[[str], _T] | FileType | None = ...,
choices: Iterable[_T] | None = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
default: _T | str | None = None,
type: Callable[[str], _T] | FileType | None = None,
choices: Iterable[_T] | None = None,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...

class Namespace(_AttributeHolder):
@@ -339,22 +339,22 @@ class FileType:
_bufsize: int
_encoding: str | None
_errors: str | None
def __init__(self, mode: str = ..., bufsize: int = ..., encoding: str | None = ..., errors: str | None = ...) -> None: ...
def __init__(self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None) -> None: ...
def __call__(self, string: str) -> IO[Any]: ...

# undocumented
class _ArgumentGroup(_ActionsContainer):
title: str | None
_group_actions: list[Action]
def __init__(
self, container: _ActionsContainer, title: str | None = ..., description: str | None = ..., **kwargs: Any
self, container: _ActionsContainer, title: str | None = None, description: str | None = None, **kwargs: Any
) -> None: ...

# undocumented
class _MutuallyExclusiveGroup(_ArgumentGroup):
required: bool
_container: _ActionsContainer
def __init__(self, container: _ActionsContainer, required: bool = ...) -> None: ...
def __init__(self, container: _ActionsContainer, required: bool = False) -> None: ...

# undocumented
class _StoreAction(Action): ...
@@ -366,34 +366,34 @@ class _StoreConstAction(Action):
self,
option_strings: Sequence[str],
dest: str,
const: Any | None = ...,
default: Any = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
const: Any | None = None,
default: Any = None,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...
else:
def __init__(
self,
option_strings: Sequence[str],
dest: str,
const: Any,
default: Any = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
default: Any = None,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...

# undocumented
class _StoreTrueAction(_StoreConstAction):
def __init__(
self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: str | None = ...
self, option_strings: Sequence[str], dest: str, default: bool = False, required: bool = False, help: str | None = None
) -> None: ...

# undocumented
class _StoreFalseAction(_StoreConstAction):
def __init__(
self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: str | None = ...
self, option_strings: Sequence[str], dest: str, default: bool = True, required: bool = False, help: str | None = None
) -> None: ...

# undocumented
@@ -410,39 +410,46 @@ class _AppendConstAction(Action):
self,
option_strings: Sequence[str],
dest: str,
const: Any | None = ...,
default: Any = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
const: Any | None = None,
default: Any = None,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...
else:
def __init__(
self,
option_strings: Sequence[str],
dest: str,
const: Any,
default: Any = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
default: Any = None,
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...

# undocumented
class _CountAction(Action):
def __init__(
self, option_strings: Sequence[str], dest: str, default: Any = ..., required: bool = ..., help: str | None = ...
self, option_strings: Sequence[str], dest: str, default: Any = None, required: bool = False, help: str | None = None
) -> None: ...

# undocumented
class _HelpAction(Action):
def __init__(self, option_strings: Sequence[str], dest: str = ..., default: str = ..., help: str | None = ...) -> None: ...
def __init__(
self, option_strings: Sequence[str], dest: str = "==SUPPRESS==", default: str = "==SUPPRESS==", help: str | None = None
) -> None: ...

# undocumented
class _VersionAction(Action):
version: str | None
def __init__(
self, option_strings: Sequence[str], version: str | None = ..., dest: str = ..., default: str = ..., help: str = ...
self,
option_strings: Sequence[str],
version: str | None = None,
dest: str = "==SUPPRESS==",
default: str = "==SUPPRESS==",
help: str = "show program's version number and exit",
) -> None: ...

# undocumented
@@ -458,10 +465,10 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
option_strings: Sequence[str],
prog: str,
parser_class: type[_ArgumentParserT],
dest: str = ...,
required: bool = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
dest: str = "==SUPPRESS==",
required: bool = False,
help: str | None = None,
metavar: str | tuple[str, ...] | None = None,
) -> None: ...

# Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/array.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, Self, SupportsRead, SupportsWrite
from collections.abc import Iterable

# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
from typing import Any, Generic, MutableSequence, TypeVar, overload # noqa: Y027
from typing import Any, Generic, MutableSequence, TypeVar, overload # noqa: Y022
from typing_extensions import Literal, SupportsIndex, TypeAlias

_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
@@ -44,12 +44,12 @@ class array(MutableSequence[_T], Generic[_T]):
def fromlist(self, __list: list[_T]) -> None: ...
def fromunicode(self, __ustr: str) -> None: ...
if sys.version_info >= (3, 10):
def index(self, __v: _T, __start: int = ..., __stop: int = ...) -> int: ...
def index(self, __v: _T, __start: int = 0, __stop: int = sys.maxsize) -> int: ...
else:
def index(self, __v: _T) -> int: ... # type: ignore[override]

def insert(self, __i: int, __v: _T) -> None: ...
def pop(self, __i: int = ...) -> _T: ...
def pop(self, __i: int = -1) -> _T: ...
def remove(self, __v: _T) -> None: ...
def tobytes(self) -> bytes: ...
def tofile(self, __f: SupportsWrite[bytes]) -> None: ...
62 changes: 33 additions & 29 deletions mypy/typeshed/stdlib/ast.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
import sys
from _ast import *
from _typeshed import ReadableBuffer
from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterator
from typing import Any, TypeVar, overload
from typing_extensions import Literal

if sys.version_info >= (3, 8):
class _ABC(type):
if sys.version_info >= (3, 9):
def __init__(cls, *args: object) -> None: ...
def __init__(cls, *args: Unused) -> None: ...

class Num(Constant, metaclass=_ABC):
value: int | float | complex
@@ -174,77 +174,79 @@ if sys.version_info >= (3, 8):
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = ...,
mode: Literal["exec"] = ...,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
mode: Literal["exec"] = "exec",
*,
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> Module: ...
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
mode: Literal["eval"],
*,
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> Expression: ...
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
mode: Literal["func_type"],
*,
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> FunctionType: ...
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any],
mode: Literal["single"],
*,
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> Interactive: ...
@overload
def parse(
source: str | ReadableBuffer,
*,
mode: Literal["eval"],
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> Expression: ...
@overload
def parse(
source: str | ReadableBuffer,
*,
mode: Literal["func_type"],
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> FunctionType: ...
@overload
def parse(
source: str | ReadableBuffer,
*,
mode: Literal["single"],
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> Interactive: ...
@overload
def parse(
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = ...,
mode: str = ...,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
mode: str = "exec",
*,
type_comments: bool = ...,
feature_version: None | int | tuple[int, int] = ...,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> AST: ...

else:
@overload
def parse(
source: str | ReadableBuffer, filename: str | ReadableBuffer | os.PathLike[Any] = ..., mode: Literal["exec"] = ...
source: str | ReadableBuffer,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
mode: Literal["exec"] = "exec",
) -> Module: ...
@overload
def parse(
@@ -259,7 +261,9 @@ else:
@overload
def parse(source: str | ReadableBuffer, *, mode: Literal["single"]) -> Interactive: ...
@overload
def parse(source: str | ReadableBuffer, filename: str | ReadableBuffer | os.PathLike[Any] = ..., mode: str = ...) -> AST: ...
def parse(
source: str | ReadableBuffer, filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>", mode: str = "exec"
) -> AST: ...

if sys.version_info >= (3, 9):
def unparse(ast_obj: AST) -> str: ...
@@ -268,21 +272,21 @@ def copy_location(new_node: _T, old_node: AST) -> _T: ...

if sys.version_info >= (3, 9):
def dump(
node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: int | str | None = ...
node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None
) -> str: ...

else:
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
def dump(node: AST, annotate_fields: bool = True, include_attributes: bool = False) -> str: ...

def fix_missing_locations(node: _T) -> _T: ...
def get_docstring(node: AsyncFunctionDef | FunctionDef | ClassDef | Module, clean: bool = ...) -> str | None: ...
def increment_lineno(node: _T, n: int = ...) -> _T: ...
def get_docstring(node: AsyncFunctionDef | FunctionDef | ClassDef | Module, clean: bool = True) -> str | None: ...
def increment_lineno(node: _T, n: int = 1) -> _T: ...
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ...
def literal_eval(node_or_string: str | AST) -> Any: ...

if sys.version_info >= (3, 8):
def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> str | None: ...
def get_source_segment(source: str, node: AST, *, padded: bool = False) -> str | None: ...

def walk(node: AST) -> Iterator[AST]: ...

2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/asynchat.pyi
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import asyncore
from abc import abstractmethod

class simple_producer:
def __init__(self, data: bytes, buffer_size: int = ...) -> None: ...
def __init__(self, data: bytes, buffer_size: int = 512) -> None: ...
def more(self) -> bytes: ...

class async_chat(asyncore.dispatcher):
312 changes: 157 additions & 155 deletions mypy/typeshed/stdlib/asyncio/base_events.pyi

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions mypy/typeshed/stdlib/asyncio/base_subprocess.pyi
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ from . import events, futures, protocols, transports
_File: TypeAlias = int | IO[Any] | None

class BaseSubprocessTransport(transports.SubprocessTransport):

_closed: bool # undocumented
_protocol: protocols.SubprocessProtocol # undocumented
_loop: events.AbstractEventLoop # undocumented
@@ -30,8 +29,8 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
stdout: _File,
stderr: _File,
bufsize: int,
waiter: futures.Future[Any] | None = ...,
extra: Any | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Any | None = None,
**kwargs: Any,
) -> None: ...
def _start(
332 changes: 166 additions & 166 deletions mypy/typeshed/stdlib/asyncio/events.pyi

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/asyncio/format_helpers.pyi
Original file line number Diff line number Diff line change
@@ -16,5 +16,5 @@ def _get_function_source(func: _FuncType) -> tuple[str, int]: ...
def _get_function_source(func: object) -> tuple[str, int] | None: ...
def _format_callback_source(func: object, args: Iterable[Any]) -> str: ...
def _format_args_and_kwargs(args: Iterable[Any], kwargs: dict[str, Any]) -> str: ...
def _format_callback(func: object, args: Iterable[Any], kwargs: dict[str, Any], suffix: str = ...) -> str: ...
def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> traceback.StackSummary: ...
def _format_callback(func: object, args: Iterable[Any], kwargs: dict[str, Any], suffix: str = "") -> str: ...
def extract_stack(f: FrameType | None = None, limit: int | None = None) -> traceback.StackSummary: ...
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/asyncio/futures.pyi
Original file line number Diff line number Diff line change
@@ -44,9 +44,9 @@ class Future(Awaitable[_T], Iterable[_T]):
def get_loop(self) -> AbstractEventLoop: ...
@property
def _callbacks(self: Self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self: Self, __fn: Callable[[Self], object], *, context: Context | None = ...) -> None: ...
def add_done_callback(self: Self, __fn: Callable[[Self], object], *, context: Context | None = None) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Any | None = ...) -> bool: ...
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...

@@ -64,4 +64,4 @@ class Future(Awaitable[_T], Iterable[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
28 changes: 14 additions & 14 deletions mypy/typeshed/stdlib/asyncio/locks.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import enum
import sys
from _typeshed import Self
from _typeshed import Self, Unused
from collections import deque
from collections.abc import Callable, Generator
from types import TracebackType
@@ -31,7 +31,7 @@ else:
class _ContextManager:
def __init__(self, lock: Lock | Semaphore) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *args: object) -> None: ...
def __exit__(self, *args: Unused) -> None: ...

class _ContextManagerMixin:
# Apparently this exists to *prohibit* use as a context manager.
@@ -45,47 +45,47 @@ else:
) -> None: ...

class Lock(_ContextManagerMixin):
if sys.version_info >= (3, 11):
if sys.version_info >= (3, 10):
def __init__(self) -> None: ...
else:
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...

def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...

class Event:
if sys.version_info >= (3, 11):
if sys.version_info >= (3, 10):
def __init__(self) -> None: ...
else:
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...

def is_set(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
async def wait(self) -> Literal[True]: ...

class Condition(_ContextManagerMixin):
if sys.version_info >= (3, 11):
def __init__(self, lock: Lock | None = ...) -> None: ...
if sys.version_info >= (3, 10):
def __init__(self, lock: Lock | None = None) -> None: ...
else:
def __init__(self, lock: Lock | None = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ...

def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...
async def wait(self) -> Literal[True]: ...
async def wait_for(self, predicate: Callable[[], _T]) -> _T: ...
def notify(self, n: int = ...) -> None: ...
def notify(self, n: int = 1) -> None: ...
def notify_all(self) -> None: ...

class Semaphore(_ContextManagerMixin):
_value: int
_waiters: deque[Future[Any]]
if sys.version_info >= (3, 11):
def __init__(self, value: int = ...) -> None: ...
if sys.version_info >= (3, 10):
def __init__(self, value: int = 1) -> None: ...
else:
def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ...

def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
@@ -104,7 +104,7 @@ if sys.version_info >= (3, 11):
class Barrier(_LoopBoundMixin):
def __init__(self, parties: int) -> None: ...
async def __aenter__(self: Self) -> Self: ...
async def __aexit__(self, *args: object) -> None: ...
async def __aexit__(self, *args: Unused) -> None: ...
async def wait(self) -> int: ...
async def abort(self) -> None: ...
async def reset(self) -> None: ...
27 changes: 13 additions & 14 deletions mypy/typeshed/stdlib/asyncio/proactor_events.pyi
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
if sys.version_info >= (3, 8):
def __del__(self, _warn: _WarnCallbackProtocol = ...) -> None: ...
@@ -36,37 +36,36 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
buffer_size: int = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
buffer_size: int = 65536,
) -> None: ...
else:
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...

class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ...
class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ...
class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ...

class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport):

_sendfile_compatible: ClassVar[constants._SendfileMode]
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = ...,
extra: Mapping[Any, Any] | None = ...,
server: events.AbstractServer | None = ...,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
def _set_extra(self, sock: socket) -> None: ...
def can_write_eof(self) -> Literal[True]: ...
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/asyncio/queues.pyi
Original file line number Diff line number Diff line change
@@ -13,10 +13,10 @@ class QueueFull(Exception): ...
_T = TypeVar("_T")

class Queue(Generic[_T]):
if sys.version_info >= (3, 11):
def __init__(self, maxsize: int = ...) -> None: ...
if sys.version_info >= (3, 10):
def __init__(self, maxsize: int = 0) -> None: ...
else:
def __init__(self, maxsize: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ...

def _init(self, maxsize: int) -> None: ...
def _get(self) -> _T: ...
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/asyncio/runners.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from _typeshed import Self
from _typeshed import Self, Unused
from collections.abc import Callable, Coroutine
from contextvars import Context
from typing import Any, TypeVar
@@ -16,20 +16,20 @@ _T = TypeVar("_T")
if sys.version_info >= (3, 11):
@final
class Runner:
def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ...
def __init__(self, *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, exc_type: object, exc_val: object, exc_tb: object) -> None: ...
def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ...
def close(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...

if sys.version_info >= (3, 12):
def run(
main: Coroutine[Any, Any, _T], *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...
) -> _T: ...

elif sys.version_info >= (3, 8):
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = ...) -> _T: ...
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = None) -> _T: ...

else:
def run(main: Coroutine[Any, Any, _T], *, debug: bool = ...) -> _T: ...
def run(main: Coroutine[Any, Any, _T], *, debug: bool = False) -> _T: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/asyncio/selector_events.pyi
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ from . import base_events
__all__ = ("BaseSelectorEventLoop",)

class BaseSelectorEventLoop(base_events.BaseEventLoop):
def __init__(self, selector: selectors.BaseSelector | None = ...) -> None: ...
def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ...
40 changes: 19 additions & 21 deletions mypy/typeshed/stdlib/asyncio/sslproto.pyi
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ else:

if sys.version_info < (3, 11):
class _SSLPipe:

max_size: ClassVar[int]

_context: ssl.SSLContext
@@ -48,7 +47,7 @@ if sys.version_info < (3, 11):
_need_ssldata: bool
_handshake_cb: Callable[[BaseException | None], None] | None
_shutdown_cb: Callable[[], None] | None
def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: str | None = ...) -> None: ...
def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: str | None = None) -> None: ...
@property
def context(self) -> ssl.SSLContext: ...
@property
@@ -57,29 +56,28 @@ if sys.version_info < (3, 11):
def need_ssldata(self) -> bool: ...
@property
def wrapped(self) -> bool: ...
def do_handshake(self, callback: Callable[[BaseException | None], object] | None = ...) -> list[bytes]: ...
def shutdown(self, callback: Callable[[], object] | None = ...) -> list[bytes]: ...
def do_handshake(self, callback: Callable[[BaseException | None], object] | None = None) -> list[bytes]: ...
def shutdown(self, callback: Callable[[], object] | None = None) -> list[bytes]: ...
def feed_eof(self) -> None: ...
def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> tuple[list[bytes], list[bytes]]: ...
def feed_appdata(self, data: bytes, offset: int = ...) -> tuple[list[bytes], int]: ...
def feed_ssldata(self, data: bytes, only_handshake: bool = False) -> tuple[list[bytes], list[bytes]]: ...
def feed_appdata(self, data: bytes, offset: int = 0) -> tuple[list[bytes], int]: ...

class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):

_sendfile_compatible: ClassVar[constants._SendfileMode]

_loop: events.AbstractEventLoop
_ssl_protocol: SSLProtocol
_closed: bool
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
def get_extra_info(self, name: str, default: Any | None = ...) -> dict[str, Any]: ...
def get_extra_info(self, name: str, default: Any | None = None) -> dict[str, Any]: ...
@property
def _protocol_paused(self) -> bool: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
def can_write_eof(self) -> Literal[False]: ...
if sys.version_info >= (3, 11):
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def get_read_buffer_limits(self) -> tuple[int, int]: ...
def set_read_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def set_read_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
def get_read_buffer_size(self) -> int: ...

if sys.version_info >= (3, 11):
@@ -118,11 +116,11 @@ class SSLProtocol(_SSLProtocolBase):
app_protocol: protocols.BaseProtocol,
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = ...,
server_hostname: str | None = ...,
call_connection_made: bool = ...,
ssl_handshake_timeout: int | None = ...,
ssl_shutdown_timeout: float | None = ...,
server_side: bool = False,
server_hostname: str | None = None,
call_connection_made: bool = True,
ssl_handshake_timeout: int | None = None,
ssl_shutdown_timeout: float | None = None,
) -> None: ...
else:
def __init__(
@@ -131,17 +129,17 @@ class SSLProtocol(_SSLProtocolBase):
app_protocol: protocols.BaseProtocol,
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = ...,
server_hostname: str | None = ...,
call_connection_made: bool = ...,
ssl_handshake_timeout: int | None = ...,
server_side: bool = False,
server_hostname: str | None = None,
call_connection_made: bool = True,
ssl_handshake_timeout: int | None = None,
) -> None: ...

def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ...
def _wakeup_waiter(self, exc: BaseException | None = ...) -> None: ...
def _wakeup_waiter(self, exc: BaseException | None = None) -> None: ...
def connection_lost(self, exc: BaseException | None) -> None: ...
def eof_received(self) -> None: ...
def _get_extra_info(self, name: str, default: Any | None = ...) -> Any: ...
def _get_extra_info(self, name: str, default: Any | None = None) -> Any: ...
def _start_shutdown(self) -> None: ...
if sys.version_info >= (3, 11):
def _write_appdata(self, list_of_data: list[bytes]) -> None: ...
@@ -151,7 +149,7 @@ class SSLProtocol(_SSLProtocolBase):
def _start_handshake(self) -> None: ...
def _check_handshake_timeout(self) -> None: ...
def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ...
def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ...
def _fatal_error(self, exc: BaseException, message: str = "Fatal error on transport") -> None: ...
def _abort(self) -> None: ...
if sys.version_info >= (3, 11):
def get_buffer(self, n: int) -> memoryview: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/asyncio/staggered.pyi
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ from . import events
__all__ = ("staggered_race",)

async def staggered_race(
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = ...
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = None
) -> tuple[Any, int | None, list[Exception | None]]: ...
56 changes: 28 additions & 28 deletions mypy/typeshed/stdlib/asyncio/streams.pyi
Original file line number Diff line number Diff line change
@@ -59,74 +59,74 @@ if sys.version_info < (3, 8):

if sys.version_info >= (3, 10):
async def open_connection(
host: str | None = ...,
port: int | str | None = ...,
host: str | None = None,
port: int | str | None = None,
*,
limit: int = ...,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> tuple[StreamReader, StreamWriter]: ...
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: str | Sequence[str] | None = ...,
port: int | str | None = ...,
host: str | Sequence[str] | None = None,
port: int | str | None = None,
*,
limit: int = ...,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Server: ...

else:
async def open_connection(
host: str | None = ...,
port: int | str | None = ...,
host: str | None = None,
port: int | str | None = None,
*,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> tuple[StreamReader, StreamWriter]: ...
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: str | None = ...,
port: int | str | None = ...,
host: str | None = None,
port: int | str | None = None,
*,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Server: ...

if sys.platform != "win32":
if sys.version_info >= (3, 10):
async def open_unix_connection(
path: StrPath | None = ..., *, limit: int = ..., **kwds: Any
path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
) -> tuple[StreamReader, StreamWriter]: ...
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback, path: StrPath | None = ..., *, limit: int = ..., **kwds: Any
client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
) -> Server: ...
else:
async def open_unix_connection(
path: StrPath | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any
path: StrPath | None = None, *, loop: events.AbstractEventLoop | None = None, limit: int = 65536, **kwds: Any
) -> tuple[StreamReader, StreamWriter]: ...
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback,
path: StrPath | None = ...,
path: StrPath | None = None,
*,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
**kwds: Any,
) -> Server: ...

class FlowControlMixin(protocols.Protocol):
def __init__(self, loop: events.AbstractEventLoop | None = ...) -> None: ...
def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ...

class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(
self,
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback | None = ...,
loop: events.AbstractEventLoop | None = ...,
client_connected_cb: _ClientConnectedCallback | None = None,
loop: events.AbstractEventLoop | None = None,
) -> None: ...

class StreamWriter:
@@ -146,15 +146,15 @@ class StreamWriter:
def close(self) -> None: ...
def is_closing(self) -> bool: ...
async def wait_closed(self) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
async def drain(self) -> None: ...
if sys.version_info >= (3, 11):
async def start_tls(
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ...
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None
) -> None: ...

class StreamReader(AsyncIterator[bytes]):
def __init__(self, limit: int = ..., loop: events.AbstractEventLoop | None = ...) -> None: ...
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
def set_transport(self, transport: transports.BaseTransport) -> None: ...
@@ -163,8 +163,8 @@ class StreamReader(AsyncIterator[bytes]):
def feed_data(self, data: Iterable[SupportsIndex]) -> None: ...
async def readline(self) -> bytes: ...
# Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted
async def readuntil(self, separator: bytes | bytearray | memoryview = ...) -> bytes: ...
async def read(self, n: int = ...) -> bytes: ...
async def readuntil(self, separator: bytes | bytearray | memoryview = b"\n") -> bytes: ...
async def read(self, n: int = -1) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...
def __aiter__(self: Self) -> Self: ...
async def __anext__(self) -> bytes: ...
54 changes: 27 additions & 27 deletions mypy/typeshed/stdlib/asyncio/subprocess.pyi
Original file line number Diff line number Diff line change
@@ -38,15 +38,15 @@ class Process:
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
async def communicate(self, input: bytes | bytearray | memoryview | None = ...) -> tuple[bytes, bytes]: ...
async def communicate(self, input: bytes | bytearray | memoryview | None = None) -> tuple[bytes, bytes]: ...

if sys.version_info >= (3, 11):
async def create_subprocess_shell(
cmd: str | bytes,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
@@ -76,10 +76,10 @@ if sys.version_info >= (3, 11):
async def create_subprocess_exec(
program: _ExecArg,
*args: _ExecArg,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
@@ -109,10 +109,10 @@ if sys.version_info >= (3, 11):
elif sys.version_info >= (3, 10):
async def create_subprocess_shell(
cmd: str | bytes,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
@@ -141,10 +141,10 @@ elif sys.version_info >= (3, 10):
async def create_subprocess_exec(
program: _ExecArg,
*args: _ExecArg,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
@@ -173,11 +173,11 @@ elif sys.version_info >= (3, 10):
else: # >= 3.9
async def create_subprocess_shell(
cmd: str | bytes,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
@@ -205,11 +205,11 @@ else: # >= 3.9
async def create_subprocess_exec(
program: _ExecArg,
*args: _ExecArg,
stdin: int | IO[Any] | None = ...,
stdout: int | IO[Any] | None = ...,
stderr: int | IO[Any] | None = ...,
loop: events.AbstractEventLoop | None = ...,
limit: int = ...,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/asyncio/taskgroups.pyi
Original file line number Diff line number Diff line change
@@ -16,5 +16,5 @@ class TaskGroup:
async def __aenter__(self: Self) -> Self: ...
async def __aexit__(self, et: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ...
def create_task(
self, coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ...
self, coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = None, context: Context | None = None
) -> Task[_T]: ...
90 changes: 49 additions & 41 deletions mypy/typeshed/stdlib/asyncio/tasks.pyi
Original file line number Diff line number Diff line change
@@ -51,17 +51,17 @@ FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED

if sys.version_info >= (3, 10):
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = ...) -> Iterator[Future[_T]]: ...
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...

else:
def as_completed(
fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ...
fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = None, timeout: float | None = None
) -> Iterator[Future[_T]]: ...

@overload
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = ...) -> _FT: ... # type: ignore[misc]
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[misc]
@overload
def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = ...) -> Task[_T]: ...
def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = None) -> Task[_T]: ...

# `gather()` actually returns a list with length equal to the number
# of tasks passed; however, Tuple is used similar to the annotation for
@@ -72,18 +72,18 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No
# but having overlapping overloads is the only way to get acceptable type inference in all edge cases.
if sys.version_info >= (3, 10):
@overload
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]: ... # type: ignore[misc]
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[misc]
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: Literal[False] = ...
__coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: Literal[False] = False
) -> Future[tuple[_T1, _T2]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
return_exceptions: Literal[False] = ...,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3]]: ...
@overload
def gather( # type: ignore[misc]
@@ -92,7 +92,7 @@ if sys.version_info >= (3, 10):
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
return_exceptions: Literal[False] = ...,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def gather( # type: ignore[misc]
@@ -102,7 +102,7 @@ if sys.version_info >= (3, 10):
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
return_exceptions: Literal[False] = ...,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[misc]
@@ -140,29 +140,29 @@ if sys.version_info >= (3, 10):
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = ...) -> Future[list[Any]]: ... # type: ignore[misc]
def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = False) -> Future[list[Any]]: ... # type: ignore[misc]

else:
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ...
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
) -> Future[tuple[_T1]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
*,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3]]: ...
@overload
def gather( # type: ignore[misc]
@@ -171,8 +171,8 @@ else:
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def gather( # type: ignore[misc]
@@ -182,19 +182,19 @@ else:
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: bool
) -> Future[tuple[_T1 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
*,
loop: AbstractEventLoop | None = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload
@@ -203,7 +203,7 @@ else:
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
loop: AbstractEventLoop | None = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
@overload
@@ -213,7 +213,7 @@ else:
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
loop: AbstractEventLoop | None = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
@overload
@@ -224,14 +224,14 @@ else:
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
loop: AbstractEventLoop | None = ...,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather( # type: ignore[misc]
*coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = ..., return_exceptions: bool = ...
*coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = None, return_exceptions: bool = False
) -> Future[list[Any]]: ...

def run_coroutine_threadsafe(coro: _FutureLike[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
@@ -243,28 +243,36 @@ if sys.version_info >= (3, 10):
@overload
async def sleep(delay: float, result: _T) -> _T: ...
@overload
async def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> tuple[set[_FT], set[_FT]]: ... # type: ignore[misc]
async def wait(fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED") -> tuple[set[_FT], set[_FT]]: ... # type: ignore[misc]
@overload
async def wait(
fs: Iterable[Awaitable[_T]], *, timeout: float | None = ..., return_when: str = ...
fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ...

else:
def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
@overload
async def sleep(delay: float, *, loop: AbstractEventLoop | None = ...) -> None: ...
async def sleep(delay: float, *, loop: AbstractEventLoop | None = None) -> None: ...
@overload
async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = ...) -> _T: ...
async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = None) -> _T: ...
@overload
async def wait( # type: ignore[misc]
fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...
fs: Iterable[_FT],
*,
loop: AbstractEventLoop | None = None,
timeout: float | None = None,
return_when: str = "ALL_COMPLETED",
) -> tuple[set[_FT], set[_FT]]: ...
@overload
async def wait(
fs: Iterable[Awaitable[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...
fs: Iterable[Awaitable[_T]],
*,
loop: AbstractEventLoop | None = None,
timeout: float | None = None,
return_when: str = "ALL_COMPLETED",
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = ...) -> _T: ...
async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ...

# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
# While this is true in general, here it's sort-of okay to have a covariant subclass,
@@ -288,33 +296,33 @@ class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright:
def get_name(self) -> str: ...
def set_name(self, __value: object) -> None: ...

def get_stack(self, *, limit: int | None = ...) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = ..., file: TextIO | None = ...) -> None: ...
def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
if sys.version_info >= (3, 11):
def cancelling(self) -> int: ...
def uncancel(self) -> int: ...
if sys.version_info < (3, 9):
@classmethod
def current_task(cls, loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ...
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop | None = ...) -> set[Task[Any]]: ...
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

def all_tasks(loop: AbstractEventLoop | None = ...) -> set[Task[Any]]: ...
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...

if sys.version_info >= (3, 11):
def create_task(
coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ...
coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = None, context: Context | None = None
) -> Task[_T]: ...

elif sys.version_info >= (3, 8):
def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ...) -> Task[_T]: ...
def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = None) -> Task[_T]: ...

else:
def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T]) -> Task[_T]: ...

def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ...
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _register_task(task: Task[Any]) -> None: ...
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/asyncio/transports.pyi
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ from typing import Any
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")

class BaseTransport:
def __init__(self, extra: Mapping[str, Any] | None = ...) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
def __init__(self, extra: Mapping[str, Any] | None = None) -> None: ...
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
def set_protocol(self, protocol: BaseProtocol) -> None: ...
@@ -20,7 +20,7 @@ class ReadTransport(BaseTransport):
def resume_reading(self) -> None: ...

class WriteTransport(BaseTransport):
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def set_write_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
def get_write_buffer_size(self) -> int: ...
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
@@ -32,7 +32,7 @@ class WriteTransport(BaseTransport):
class Transport(ReadTransport, WriteTransport): ...

class DatagramTransport(BaseTransport):
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = ...) -> None: ...
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = None) -> None: ...
def abort(self) -> None: ...

class SubprocessTransport(BaseTransport):
@@ -44,4 +44,4 @@ class SubprocessTransport(BaseTransport):
def kill(self) -> None: ...

class _FlowControlMixin(Transport):
def __init__(self, extra: Mapping[str, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, extra: Mapping[str, Any] | None = None, loop: AbstractEventLoop | None = None) -> None: ...
1 change: 0 additions & 1 deletion mypy/typeshed/stdlib/asyncio/unix_events.pyi
Original file line number Diff line number Diff line change
@@ -85,7 +85,6 @@ if sys.platform != "win32":
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy

if sys.version_info >= (3, 8):

from typing import Protocol

class _Warn(Protocol):
14 changes: 7 additions & 7 deletions mypy/typeshed/stdlib/asyncio/windows_events.pyi
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ if sys.platform == "win32":
class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ...

class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
def __init__(self, proactor: IocpProactor | None = ...) -> None: ...
def __init__(self, proactor: IocpProactor | None = None) -> None: ...
async def create_pipe_connection(
self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str
) -> tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ...
@@ -42,13 +42,13 @@ if sys.platform == "win32":
) -> list[PipeServer]: ...

class IocpProactor:
def __init__(self, concurrency: int = ...) -> None: ...
def __init__(self, concurrency: int = 0xFFFFFFFF) -> None: ...
def __del__(self) -> None: ...
def set_loop(self, loop: events.AbstractEventLoop) -> None: ...
def select(self, timeout: int | None = ...) -> list[futures.Future[Any]]: ...
def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ...
def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ...
def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ...
def select(self, timeout: int | None = None) -> list[futures.Future[Any]]: ...
def recv(self, conn: socket.socket, nbytes: int, flags: int = 0) -> futures.Future[bytes]: ...
def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
def accept(self, listener: socket.socket) -> futures.Future[Any]: ...
def connect(
self,
@@ -58,7 +58,7 @@ if sys.platform == "win32":
def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ...
def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ...
async def connect_pipe(self, address: str) -> windows_utils.PipeHandle: ...
def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = ...) -> bool: ...
def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = None) -> bool: ...
def close(self) -> None: ...
SelectorEventLoop = _WindowsSelectorEventLoop

8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/asyncio/windows_utils.pyi
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ if sys.platform == "win32":
BUFSIZE: Literal[8192]
PIPE = subprocess.PIPE
STDOUT = subprocess.STDOUT
def pipe(*, duplex: bool = ..., overlapped: tuple[bool, bool] = ..., bufsize: int = ...) -> tuple[int, int]: ...
def pipe(*, duplex: bool = False, overlapped: tuple[bool, bool] = ..., bufsize: int = 8192) -> tuple[int, int]: ...

class PipeHandle:
def __init__(self, handle: int) -> None: ...
@@ -51,8 +51,8 @@ if sys.platform == "win32":
def __init__(
self,
args: subprocess._CMD,
stdin: subprocess._FILE | None = ...,
stdout: subprocess._FILE | None = ...,
stderr: subprocess._FILE | None = ...,
stdin: subprocess._FILE | None = None,
stdout: subprocess._FILE | None = None,
stderr: subprocess._FILE | None = None,
**kwds: Any,
) -> None: ...
23 changes: 11 additions & 12 deletions mypy/typeshed/stdlib/asyncore.pyi
Original file line number Diff line number Diff line change
@@ -15,29 +15,28 @@ class ExitNow(Exception): ...
def read(obj: Any) -> None: ...
def write(obj: Any) -> None: ...
def readwrite(obj: Any, flags: int) -> None: ...
def poll(timeout: float = ..., map: _MapType | None = ...) -> None: ...
def poll2(timeout: float = ..., map: _MapType | None = ...) -> None: ...
def poll(timeout: float = 0.0, map: _MapType | None = None) -> None: ...
def poll2(timeout: float = 0.0, map: _MapType | None = None) -> None: ...

poll3 = poll2

def loop(timeout: float = ..., use_poll: bool = ..., map: _MapType | None = ..., count: int | None = ...) -> None: ...
def loop(timeout: float = 30.0, use_poll: bool = False, map: _MapType | None = None, count: int | None = None) -> None: ...

# Not really subclass of socket.socket; it's only delegation.
# It is not covariant to it.
class dispatcher:

debug: bool
connected: bool
accepting: bool
connecting: bool
closing: bool
ignore_log_types: frozenset[str]
socket: _Socket | None
def __init__(self, sock: _Socket | None = ..., map: _MapType | None = ...) -> None: ...
def add_channel(self, map: _MapType | None = ...) -> None: ...
def del_channel(self, map: _MapType | None = ...) -> None: ...
def __init__(self, sock: _Socket | None = None, map: _MapType | None = None) -> None: ...
def add_channel(self, map: _MapType | None = None) -> None: ...
def del_channel(self, map: _MapType | None = None) -> None: ...
def create_socket(self, family: int = ..., type: int = ...) -> None: ...
def set_socket(self, sock: _Socket, map: _MapType | None = ...) -> None: ...
def set_socket(self, sock: _Socket, map: _MapType | None = None) -> None: ...
def set_reuse_addr(self) -> None: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
@@ -49,7 +48,7 @@ class dispatcher:
def recv(self, buffer_size: int) -> bytes: ...
def close(self) -> None: ...
def log(self, message: Any) -> None: ...
def log_info(self, message: Any, type: str = ...) -> None: ...
def log_info(self, message: Any, type: str = "info") -> None: ...
def handle_read_event(self) -> None: ...
def handle_connect_event(self) -> None: ...
def handle_write_event(self) -> None: ...
@@ -68,7 +67,7 @@ class dispatcher_with_send(dispatcher):
# def send(self, data: bytes) -> int | None: ...

def compact_traceback() -> tuple[tuple[str, str, str], type, type, str]: ...
def close_all(map: _MapType | None = ..., ignore_all: bool = ...) -> None: ...
def close_all(map: _MapType | None = None, ignore_all: bool = False) -> None: ...

if sys.platform != "win32":
class file_wrapper:
@@ -77,7 +76,7 @@ if sys.platform != "win32":
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
def send(self, data: bytes, flags: int = ...) -> int: ...
@overload
def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ...
def getsockopt(self, level: int, optname: int, buflen: None = None) -> int: ...
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
def read(self, bufsize: int, flags: int = ...) -> bytes: ...
@@ -86,5 +85,5 @@ if sys.platform != "win32":
def fileno(self) -> int: ...

class file_dispatcher(dispatcher):
def __init__(self, fd: FileDescriptorLike, map: _MapType | None = ...) -> None: ...
def __init__(self, fd: FileDescriptorLike, map: _MapType | None = None) -> None: ...
def set_file(self, fd: int) -> None: ...
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/audioop.pyi
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@ def ratecv(
__inrate: int,
__outrate: int,
__state: _RatecvState | None,
__weightA: int = ...,
__weightB: int = ...,
__weightA: int = 1,
__weightB: int = 0,
) -> tuple[bytes, _RatecvState]: ...
def reverse(__fragment: bytes, __width: int) -> bytes: ...
def rms(__fragment: bytes, __width: int) -> int: ...
Loading