Skip to content

Commit a0dbbd5

Browse files
Sync typeshed (#17619)
Source commit: python/typeshed@4ef2d66
1 parent 8b74b5a commit a0dbbd5

37 files changed

+418
-405
lines changed

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,7 @@ def tparm(
368368
) -> bytes: ...
369369
def typeahead(fd: int, /) -> None: ...
370370
def unctrl(ch: _ChType, /) -> bytes: ...
371-
372-
if sys.version_info < (3, 12) or sys.platform != "darwin":
373-
# The support for macos was dropped in 3.12
374-
def unget_wch(ch: int | str, /) -> None: ...
375-
371+
def unget_wch(ch: int | str, /) -> None: ...
376372
def ungetch(ch: _ChType, /) -> None: ...
377373
def ungetmouse(id: int, x: int, y: int, z: int, bstate: int, /) -> None: ...
378374
def update_lines_cols() -> None: ...
@@ -447,13 +443,10 @@ class _CursesWindow:
447443
def getch(self) -> int: ...
448444
@overload
449445
def getch(self, y: int, x: int) -> int: ...
450-
if sys.version_info < (3, 12) or sys.platform != "darwin":
451-
# The support for macos was dropped in 3.12
452-
@overload
453-
def get_wch(self) -> int | str: ...
454-
@overload
455-
def get_wch(self, y: int, x: int) -> int | str: ...
456-
446+
@overload
447+
def get_wch(self) -> int | str: ...
448+
@overload
449+
def get_wch(self, y: int, x: int) -> int | str: ...
457450
@overload
458451
def getkey(self) -> str: ...
459452
@overload

mypy/typeshed/stdlib/_decimal.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ class DecimalTuple(NamedTuple):
1717
digits: tuple[int, ...]
1818
exponent: int | Literal["n", "N", "F"]
1919

20-
ROUND_DOWN: str
21-
ROUND_HALF_UP: str
22-
ROUND_HALF_EVEN: str
23-
ROUND_CEILING: str
24-
ROUND_FLOOR: str
25-
ROUND_UP: str
26-
ROUND_HALF_DOWN: str
27-
ROUND_05UP: str
28-
HAVE_CONTEXTVAR: bool
29-
HAVE_THREADS: bool
30-
MAX_EMAX: int
31-
MAX_PREC: int
32-
MIN_EMIN: int
33-
MIN_ETINY: int
20+
ROUND_DOWN: Final[str]
21+
ROUND_HALF_UP: Final[str]
22+
ROUND_HALF_EVEN: Final[str]
23+
ROUND_CEILING: Final[str]
24+
ROUND_FLOOR: Final[str]
25+
ROUND_UP: Final[str]
26+
ROUND_HALF_DOWN: Final[str]
27+
ROUND_05UP: Final[str]
28+
HAVE_CONTEXTVAR: Final[bool]
29+
HAVE_THREADS: Final[bool]
30+
MAX_EMAX: Final[int]
31+
MAX_PREC: Final[int]
32+
MIN_EMIN: Final[int]
33+
MIN_ETINY: Final[int]
3434

3535
class DecimalException(ArithmeticError): ...
3636
class Clamped(DecimalException): ...

mypy/typeshed/stdlib/_osx_support.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
from collections.abc import Iterable, Sequence
2-
from typing import TypeVar
2+
from typing import Final, TypeVar
33

44
_T = TypeVar("_T")
55
_K = TypeVar("_K")
66
_V = TypeVar("_V")
77

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

10-
_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented
11-
_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
12-
_INITPRE: str # undocumented
10+
_UNIVERSAL_CONFIG_VARS: Final[tuple[str, ...]] # undocumented
11+
_COMPILER_CONFIG_VARS: Final[tuple[str, ...]] # undocumented
12+
_INITPRE: Final[str] # undocumented
1313

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

18-
_SYSTEM_VERSION: str | None # undocumented
18+
_SYSTEM_VERSION: Final[str | None] # undocumented
1919

2020
def _get_system_version() -> str: ... # undocumented
2121
def _remove_original_values(_config_vars: dict[str, str]) -> None: ... # undocumented

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ _SUPPRESS_T = NewType("_SUPPRESS_T", str)
5151
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
5252
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
5353
ZERO_OR_MORE: Final = "*"
54-
_UNRECOGNIZED_ARGS_ATTR: str # undocumented
54+
_UNRECOGNIZED_ARGS_ATTR: Final[str] # undocumented
5555

5656
class ArgumentError(Exception):
5757
argument_name: str | None

mypy/typeshed/stdlib/asyncio/tasks.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,11 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
429429
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
430430
) -> None: ...
431431

432-
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
432+
if sys.version_info >= (3, 12):
433+
def get_coro(self) -> _TaskCompatibleCoro[_T_co] | None: ...
434+
else:
435+
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
436+
433437
def get_name(self) -> str: ...
434438
def set_name(self, value: object, /) -> None: ...
435439
if sys.version_info >= (3, 12):

mypy/typeshed/stdlib/email/charset.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from collections.abc import Callable, Iterator
22
from email.message import Message
3-
from typing import overload
3+
from typing import Final, overload
44

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

7-
QP: int # undocumented
8-
BASE64: int # undocumented
9-
SHORTEST: int # undocumented
7+
QP: Final[int] # undocumented
8+
BASE64: Final[int] # undocumented
9+
SHORTEST: Final[int] # undocumented
1010

1111
class Charset:
1212
input_charset: str

mypy/typeshed/stdlib/gzip.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import sys
33
import zlib
44
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath
55
from io import FileIO
6-
from typing import Literal, Protocol, TextIO, overload
6+
from typing import Final, Literal, Protocol, TextIO, overload
77
from typing_extensions import TypeAlias
88

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

15-
READ: object # undocumented
16-
WRITE: object # undocumented
15+
READ: Final[object] # undocumented
16+
WRITE: Final[object] # undocumented
1717

18-
FTEXT: int # actually Literal[1] # undocumented
19-
FHCRC: int # actually Literal[2] # undocumented
20-
FEXTRA: int # actually Literal[4] # undocumented
21-
FNAME: int # actually Literal[8] # undocumented
22-
FCOMMENT: int # actually Literal[16] # undocumented
18+
FTEXT: Final[int] # actually Literal[1] # undocumented
19+
FHCRC: Final[int] # actually Literal[2] # undocumented
20+
FEXTRA: Final[int] # actually Literal[4] # undocumented
21+
FNAME: Final[int] # actually Literal[8] # undocumented
22+
FCOMMENT: Final[int] # actually Literal[16] # undocumented
2323

2424
class _ReadableFileobj(Protocol):
2525
def read(self, n: int, /) -> bytes: ...

mypy/typeshed/stdlib/io.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class _WrappedBuffer(Protocol):
168168
def writable(self) -> bool: ...
169169
def truncate(self, size: int, /) -> int: ...
170170
def fileno(self) -> int: ...
171-
def isatty(self) -> int: ...
171+
def isatty(self) -> bool: ...
172172
# Optional: Only needs to be present if seekable() returns True.
173173
# def seek(self, offset: Literal[0], whence: Literal[2]) -> int: ...
174174
# def tell(self) -> int: ...

mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import ClassVar, Literal
1+
from typing import ClassVar, Final, Literal
22

33
from ..fixer_base import BaseFix
44

5-
NAMES: dict[str, str]
5+
NAMES: Final[dict[str, str]]
66

77
class FixAsserts(BaseFix):
88
BM_compatible: ClassVar[Literal[False]]

mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import ClassVar, Literal
1+
from typing import ClassVar, Final, Literal
22

33
from .. import fixer_base
44

5-
CMP: str
6-
TYPE: str
5+
CMP: Final[str]
6+
TYPE: Final[str]
77

88
class FixIdioms(fixer_base.BaseFix):
99
BM_compatible: ClassVar[Literal[False]]

mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from _typeshed import StrPath
22
from collections.abc import Generator
3-
from typing import ClassVar, Literal
3+
from typing import ClassVar, Final, Literal
44

55
from .. import fixer_base
66
from ..pytree import Node
77

8-
MAPPING: dict[str, str]
8+
MAPPING: Final[dict[str, str]]
99

1010
def alternates(members): ...
1111
def build_pattern(mapping=...) -> Generator[str, None, None]: ...
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from typing import Final
2+
13
from . import fix_imports
24

3-
MAPPING: dict[str, str]
5+
MAPPING: Final[dict[str, str]]
46

57
class FixImports2(fix_imports.FixImports):
68
mapping = MAPPING

mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import ClassVar, Literal
1+
from typing import ClassVar, Final, Literal
22

33
from .. import fixer_base
44

5-
MAP: dict[str, str]
5+
MAP: Final[dict[str, str]]
66

77
class FixMethodattrs(fixer_base.BaseFix):
88
BM_compatible: ClassVar[Literal[True]]

mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from collections.abc import Generator
2-
from typing import ClassVar, Literal
2+
from typing import ClassVar, Final, Literal
33

44
from .. import fixer_base
55

6-
MAPPING: dict[str, dict[str, str]]
7-
LOOKUP: dict[tuple[str, str], str]
6+
MAPPING: Final[dict[str, dict[str, str]]]
7+
LOOKUP: Final[dict[tuple[str, str], str]]
88

99
def alternates(members): ...
1010
def build_pattern() -> Generator[str, None, None]: ...

mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from collections.abc import Generator
2-
from typing import Literal
2+
from typing import Final, Literal
33

44
from .fix_imports import FixImports
55

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

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

mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,67 @@
1-
ENDMARKER: int
2-
NAME: int
3-
NUMBER: int
4-
STRING: int
5-
NEWLINE: int
6-
INDENT: int
7-
DEDENT: int
8-
LPAR: int
9-
RPAR: int
10-
LSQB: int
11-
RSQB: int
12-
COLON: int
13-
COMMA: int
14-
SEMI: int
15-
PLUS: int
16-
MINUS: int
17-
STAR: int
18-
SLASH: int
19-
VBAR: int
20-
AMPER: int
21-
LESS: int
22-
GREATER: int
23-
EQUAL: int
24-
DOT: int
25-
PERCENT: int
26-
BACKQUOTE: int
27-
LBRACE: int
28-
RBRACE: int
29-
EQEQUAL: int
30-
NOTEQUAL: int
31-
LESSEQUAL: int
32-
GREATEREQUAL: int
33-
TILDE: int
34-
CIRCUMFLEX: int
35-
LEFTSHIFT: int
36-
RIGHTSHIFT: int
37-
DOUBLESTAR: int
38-
PLUSEQUAL: int
39-
MINEQUAL: int
40-
STAREQUAL: int
41-
SLASHEQUAL: int
42-
PERCENTEQUAL: int
43-
AMPEREQUAL: int
44-
VBAREQUAL: int
45-
CIRCUMFLEXEQUAL: int
46-
LEFTSHIFTEQUAL: int
47-
RIGHTSHIFTEQUAL: int
48-
DOUBLESTAREQUAL: int
49-
DOUBLESLASH: int
50-
DOUBLESLASHEQUAL: int
51-
OP: int
52-
COMMENT: int
53-
NL: int
54-
RARROW: int
55-
AT: int
56-
ATEQUAL: int
57-
AWAIT: int
58-
ASYNC: int
59-
ERRORTOKEN: int
60-
COLONEQUAL: int
61-
N_TOKENS: int
62-
NT_OFFSET: int
1+
from typing import Final
2+
3+
ENDMARKER: Final[int]
4+
NAME: Final[int]
5+
NUMBER: Final[int]
6+
STRING: Final[int]
7+
NEWLINE: Final[int]
8+
INDENT: Final[int]
9+
DEDENT: Final[int]
10+
LPAR: Final[int]
11+
RPAR: Final[int]
12+
LSQB: Final[int]
13+
RSQB: Final[int]
14+
COLON: Final[int]
15+
COMMA: Final[int]
16+
SEMI: Final[int]
17+
PLUS: Final[int]
18+
MINUS: Final[int]
19+
STAR: Final[int]
20+
SLASH: Final[int]
21+
VBAR: Final[int]
22+
AMPER: Final[int]
23+
LESS: Final[int]
24+
GREATER: Final[int]
25+
EQUAL: Final[int]
26+
DOT: Final[int]
27+
PERCENT: Final[int]
28+
BACKQUOTE: Final[int]
29+
LBRACE: Final[int]
30+
RBRACE: Final[int]
31+
EQEQUAL: Final[int]
32+
NOTEQUAL: Final[int]
33+
LESSEQUAL: Final[int]
34+
GREATEREQUAL: Final[int]
35+
TILDE: Final[int]
36+
CIRCUMFLEX: Final[int]
37+
LEFTSHIFT: Final[int]
38+
RIGHTSHIFT: Final[int]
39+
DOUBLESTAR: Final[int]
40+
PLUSEQUAL: Final[int]
41+
MINEQUAL: Final[int]
42+
STAREQUAL: Final[int]
43+
SLASHEQUAL: Final[int]
44+
PERCENTEQUAL: Final[int]
45+
AMPEREQUAL: Final[int]
46+
VBAREQUAL: Final[int]
47+
CIRCUMFLEXEQUAL: Final[int]
48+
LEFTSHIFTEQUAL: Final[int]
49+
RIGHTSHIFTEQUAL: Final[int]
50+
DOUBLESTAREQUAL: Final[int]
51+
DOUBLESLASH: Final[int]
52+
DOUBLESLASHEQUAL: Final[int]
53+
OP: Final[int]
54+
COMMENT: Final[int]
55+
NL: Final[int]
56+
RARROW: Final[int]
57+
AT: Final[int]
58+
ATEQUAL: Final[int]
59+
AWAIT: Final[int]
60+
ASYNC: Final[int]
61+
ERRORTOKEN: Final[int]
62+
COLONEQUAL: Final[int]
63+
N_TOKENS: Final[int]
64+
NT_OFFSET: Final[int]
6365
tok_name: dict[int, str]
6466

6567
def ISTERMINAL(x: int) -> bool: ...

0 commit comments

Comments
 (0)