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]]

0 commit comments

Comments
 (0)