Skip to content

Commit

Permalink
Sync typeshed (#17619)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 1, 2024
1 parent 8b74b5a commit a0dbbd5
Show file tree
Hide file tree
Showing 37 changed files with 418 additions and 405 deletions.
17 changes: 5 additions & 12 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,7 @@ def tparm(
) -> bytes: ...
def typeahead(fd: int, /) -> None: ...
def unctrl(ch: _ChType, /) -> bytes: ...

if sys.version_info < (3, 12) or sys.platform != "darwin":
# The support for macos was dropped in 3.12
def unget_wch(ch: int | str, /) -> None: ...

def unget_wch(ch: int | str, /) -> None: ...
def ungetch(ch: _ChType, /) -> None: ...
def ungetmouse(id: int, x: int, y: int, z: int, bstate: int, /) -> None: ...
def update_lines_cols() -> None: ...
Expand Down Expand Up @@ -447,13 +443,10 @@ class _CursesWindow:
def getch(self) -> int: ...
@overload
def getch(self, y: int, x: int) -> int: ...
if sys.version_info < (3, 12) or sys.platform != "darwin":
# The support for macos was dropped in 3.12
@overload
def get_wch(self) -> int | str: ...
@overload
def get_wch(self, y: int, x: int) -> int | str: ...

@overload
def get_wch(self) -> int | str: ...
@overload
def get_wch(self, y: int, x: int) -> int | str: ...
@overload
def getkey(self) -> str: ...
@overload
Expand Down
28 changes: 14 additions & 14 deletions mypy/typeshed/stdlib/_decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ class DecimalTuple(NamedTuple):
digits: tuple[int, ...]
exponent: int | Literal["n", "N", "F"]

ROUND_DOWN: str
ROUND_HALF_UP: str
ROUND_HALF_EVEN: str
ROUND_CEILING: str
ROUND_FLOOR: str
ROUND_UP: str
ROUND_HALF_DOWN: str
ROUND_05UP: str
HAVE_CONTEXTVAR: bool
HAVE_THREADS: bool
MAX_EMAX: int
MAX_PREC: int
MIN_EMIN: int
MIN_ETINY: int
ROUND_DOWN: Final[str]
ROUND_HALF_UP: Final[str]
ROUND_HALF_EVEN: Final[str]
ROUND_CEILING: Final[str]
ROUND_FLOOR: Final[str]
ROUND_UP: Final[str]
ROUND_HALF_DOWN: Final[str]
ROUND_05UP: Final[str]
HAVE_CONTEXTVAR: Final[bool]
HAVE_THREADS: Final[bool]
MAX_EMAX: Final[int]
MAX_PREC: Final[int]
MIN_EMIN: Final[int]
MIN_ETINY: Final[int]

class DecimalException(ArithmeticError): ...
class Clamped(DecimalException): ...
Expand Down
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from collections.abc import Iterable, Sequence
from typing import TypeVar
from typing import Final, TypeVar

_T = TypeVar("_T")
_K = TypeVar("_K")
_V = TypeVar("_V")

__all__ = ["compiler_fixup", "customize_config_vars", "customize_compiler", "get_platform_osx"]

_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented
_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
_INITPRE: str # undocumented
_UNIVERSAL_CONFIG_VARS: Final[tuple[str, ...]] # undocumented
_COMPILER_CONFIG_VARS: Final[tuple[str, ...]] # undocumented
_INITPRE: Final[str] # undocumented

def _find_executable(executable: str, path: str | None = None) -> str | None: ... # undocumented
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented
def _find_build_tool(toolname: str) -> str: ... # undocumented

_SYSTEM_VERSION: str | None # undocumented
_SYSTEM_VERSION: Final[str | None] # undocumented

def _get_system_version() -> str: ... # undocumented
def _remove_original_values(_config_vars: dict[str, str]) -> None: ... # undocumented
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ _SUPPRESS_T = NewType("_SUPPRESS_T", str)
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
ZERO_OR_MORE: Final = "*"
_UNRECOGNIZED_ARGS_ATTR: str # undocumented
_UNRECOGNIZED_ARGS_ATTR: Final[str] # undocumented

class ArgumentError(Exception):
argument_name: str | None
Expand Down
6 changes: 5 additions & 1 deletion mypy/typeshed/stdlib/asyncio/tasks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
) -> None: ...

def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
if sys.version_info >= (3, 12):
def get_coro(self) -> _TaskCompatibleCoro[_T_co] | None: ...
else:
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...

def get_name(self) -> str: ...
def set_name(self, value: object, /) -> None: ...
if sys.version_info >= (3, 12):
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/email/charset.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from collections.abc import Callable, Iterator
from email.message import Message
from typing import overload
from typing import Final, overload

__all__ = ["Charset", "add_alias", "add_charset", "add_codec"]

QP: int # undocumented
BASE64: int # undocumented
SHORTEST: int # undocumented
QP: Final[int] # undocumented
BASE64: Final[int] # undocumented
SHORTEST: Final[int] # undocumented

class Charset:
input_charset: str
Expand Down
16 changes: 8 additions & 8 deletions mypy/typeshed/stdlib/gzip.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sys
import zlib
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath
from io import FileIO
from typing import Literal, Protocol, TextIO, overload
from typing import Final, Literal, Protocol, TextIO, overload
from typing_extensions import TypeAlias

__all__ = ["BadGzipFile", "GzipFile", "open", "compress", "decompress"]
Expand All @@ -12,14 +12,14 @@ _ReadBinaryMode: TypeAlias = Literal["r", "rb"]
_WriteBinaryMode: TypeAlias = Literal["a", "ab", "w", "wb", "x", "xb"]
_OpenTextMode: TypeAlias = Literal["rt", "at", "wt", "xt"]

READ: object # undocumented
WRITE: object # undocumented
READ: Final[object] # undocumented
WRITE: Final[object] # undocumented

FTEXT: int # actually Literal[1] # undocumented
FHCRC: int # actually Literal[2] # undocumented
FEXTRA: int # actually Literal[4] # undocumented
FNAME: int # actually Literal[8] # undocumented
FCOMMENT: int # actually Literal[16] # undocumented
FTEXT: Final[int] # actually Literal[1] # undocumented
FHCRC: Final[int] # actually Literal[2] # undocumented
FEXTRA: Final[int] # actually Literal[4] # undocumented
FNAME: Final[int] # actually Literal[8] # undocumented
FCOMMENT: Final[int] # actually Literal[16] # undocumented

class _ReadableFileobj(Protocol):
def read(self, n: int, /) -> bytes: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class _WrappedBuffer(Protocol):
def writable(self) -> bool: ...
def truncate(self, size: int, /) -> int: ...
def fileno(self) -> int: ...
def isatty(self) -> int: ...
def isatty(self) -> bool: ...
# Optional: Only needs to be present if seekable() returns True.
# def seek(self, offset: Literal[0], whence: Literal[2]) -> int: ...
# def tell(self) -> int: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import ClassVar, Literal
from typing import ClassVar, Final, Literal

from ..fixer_base import BaseFix

NAMES: dict[str, str]
NAMES: Final[dict[str, str]]

class FixAsserts(BaseFix):
BM_compatible: ClassVar[Literal[False]]
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import ClassVar, Literal
from typing import ClassVar, Final, Literal

from .. import fixer_base

CMP: str
TYPE: str
CMP: Final[str]
TYPE: Final[str]

class FixIdioms(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[False]]
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from _typeshed import StrPath
from collections.abc import Generator
from typing import ClassVar, Literal
from typing import ClassVar, Final, Literal

from .. import fixer_base
from ..pytree import Node

MAPPING: dict[str, str]
MAPPING: Final[dict[str, str]]

def alternates(members): ...
def build_pattern(mapping=...) -> Generator[str, None, None]: ...
Expand Down
4 changes: 3 additions & 1 deletion mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Final

from . import fix_imports

MAPPING: dict[str, str]
MAPPING: Final[dict[str, str]]

class FixImports2(fix_imports.FixImports):
mapping = MAPPING
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import ClassVar, Literal
from typing import ClassVar, Final, Literal

from .. import fixer_base

MAP: dict[str, str]
MAP: Final[dict[str, str]]

class FixMethodattrs(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
Expand Down
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from collections.abc import Generator
from typing import ClassVar, Literal
from typing import ClassVar, Final, Literal

from .. import fixer_base

MAPPING: dict[str, dict[str, str]]
LOOKUP: dict[tuple[str, str], str]
MAPPING: Final[dict[str, dict[str, str]]]
LOOKUP: Final[dict[tuple[str, str], str]]

def alternates(members): ...
def build_pattern() -> Generator[str, None, None]: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from collections.abc import Generator
from typing import Literal
from typing import Final, Literal

from .fix_imports import FixImports

MAPPING: dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]]
MAPPING: Final[dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]]]

def build_pattern() -> Generator[str, None, None]: ...

Expand Down
126 changes: 64 additions & 62 deletions mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
ENDMARKER: int
NAME: int
NUMBER: int
STRING: int
NEWLINE: int
INDENT: int
DEDENT: int
LPAR: int
RPAR: int
LSQB: int
RSQB: int
COLON: int
COMMA: int
SEMI: int
PLUS: int
MINUS: int
STAR: int
SLASH: int
VBAR: int
AMPER: int
LESS: int
GREATER: int
EQUAL: int
DOT: int
PERCENT: int
BACKQUOTE: int
LBRACE: int
RBRACE: int
EQEQUAL: int
NOTEQUAL: int
LESSEQUAL: int
GREATEREQUAL: int
TILDE: int
CIRCUMFLEX: int
LEFTSHIFT: int
RIGHTSHIFT: int
DOUBLESTAR: int
PLUSEQUAL: int
MINEQUAL: int
STAREQUAL: int
SLASHEQUAL: int
PERCENTEQUAL: int
AMPEREQUAL: int
VBAREQUAL: int
CIRCUMFLEXEQUAL: int
LEFTSHIFTEQUAL: int
RIGHTSHIFTEQUAL: int
DOUBLESTAREQUAL: int
DOUBLESLASH: int
DOUBLESLASHEQUAL: int
OP: int
COMMENT: int
NL: int
RARROW: int
AT: int
ATEQUAL: int
AWAIT: int
ASYNC: int
ERRORTOKEN: int
COLONEQUAL: int
N_TOKENS: int
NT_OFFSET: int
from typing import Final

ENDMARKER: Final[int]
NAME: Final[int]
NUMBER: Final[int]
STRING: Final[int]
NEWLINE: Final[int]
INDENT: Final[int]
DEDENT: Final[int]
LPAR: Final[int]
RPAR: Final[int]
LSQB: Final[int]
RSQB: Final[int]
COLON: Final[int]
COMMA: Final[int]
SEMI: Final[int]
PLUS: Final[int]
MINUS: Final[int]
STAR: Final[int]
SLASH: Final[int]
VBAR: Final[int]
AMPER: Final[int]
LESS: Final[int]
GREATER: Final[int]
EQUAL: Final[int]
DOT: Final[int]
PERCENT: Final[int]
BACKQUOTE: Final[int]
LBRACE: Final[int]
RBRACE: Final[int]
EQEQUAL: Final[int]
NOTEQUAL: Final[int]
LESSEQUAL: Final[int]
GREATEREQUAL: Final[int]
TILDE: Final[int]
CIRCUMFLEX: Final[int]
LEFTSHIFT: Final[int]
RIGHTSHIFT: Final[int]
DOUBLESTAR: Final[int]
PLUSEQUAL: Final[int]
MINEQUAL: Final[int]
STAREQUAL: Final[int]
SLASHEQUAL: Final[int]
PERCENTEQUAL: Final[int]
AMPEREQUAL: Final[int]
VBAREQUAL: Final[int]
CIRCUMFLEXEQUAL: Final[int]
LEFTSHIFTEQUAL: Final[int]
RIGHTSHIFTEQUAL: Final[int]
DOUBLESTAREQUAL: Final[int]
DOUBLESLASH: Final[int]
DOUBLESLASHEQUAL: Final[int]
OP: Final[int]
COMMENT: Final[int]
NL: Final[int]
RARROW: Final[int]
AT: Final[int]
ATEQUAL: Final[int]
AWAIT: Final[int]
ASYNC: Final[int]
ERRORTOKEN: Final[int]
COLONEQUAL: Final[int]
N_TOKENS: Final[int]
NT_OFFSET: Final[int]
tok_name: dict[int, str]

def ISTERMINAL(x: int) -> bool: ...
Expand Down
Loading

0 comments on commit a0dbbd5

Please sign in to comment.