Skip to content

Commit 67c3969

Browse files
jhancehauntsaninjaAlexWaygood
authored
Sync Typeshed (for 1.9 release) (#16844)
Co-authored-by: Shantanu <[email protected]> Co-authored-by: AlexWaygood <[email protected]>
1 parent ba90dc4 commit 67c3969

File tree

261 files changed

+2887
-4617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+2887
-4617
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ linecache: 3.0-
170170
locale: 3.0-
171171
logging: 3.0-
172172
lzma: 3.3-
173-
macpath: 3.0-3.7
174173
mailbox: 3.0-
175174
mailcap: 3.0-3.12
176175
marshal: 3.0-

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import sys
22
import typing_extensions
3-
from typing import Any, ClassVar
4-
from typing_extensions import Literal
3+
from typing import Any, ClassVar, Literal
54

65
PyCF_ONLY_AST: Literal[1024]
7-
if sys.version_info >= (3, 8):
8-
PyCF_TYPE_COMMENTS: Literal[4096]
9-
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
6+
PyCF_TYPE_COMMENTS: Literal[4096]
7+
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
108

119
_Identifier: typing_extensions.TypeAlias = str
1210

@@ -19,33 +17,29 @@ class AST:
1917
# TODO: Not all nodes have all of the following attributes
2018
lineno: int
2119
col_offset: int
22-
if sys.version_info >= (3, 8):
23-
end_lineno: int | None
24-
end_col_offset: int | None
25-
type_comment: str | None
20+
end_lineno: int | None
21+
end_col_offset: int | None
22+
type_comment: str | None
2623

2724
class mod(AST): ...
25+
class type_ignore(AST): ...
2826

29-
if sys.version_info >= (3, 8):
30-
class type_ignore(AST): ...
31-
32-
class TypeIgnore(type_ignore):
33-
if sys.version_info >= (3, 10):
34-
__match_args__ = ("lineno", "tag")
35-
tag: str
27+
class TypeIgnore(type_ignore):
28+
if sys.version_info >= (3, 10):
29+
__match_args__ = ("lineno", "tag")
30+
tag: str
3631

37-
class FunctionType(mod):
38-
if sys.version_info >= (3, 10):
39-
__match_args__ = ("argtypes", "returns")
40-
argtypes: list[expr]
41-
returns: expr
32+
class FunctionType(mod):
33+
if sys.version_info >= (3, 10):
34+
__match_args__ = ("argtypes", "returns")
35+
argtypes: list[expr]
36+
returns: expr
4237

4338
class Module(mod):
4439
if sys.version_info >= (3, 10):
4540
__match_args__ = ("body", "type_ignores")
4641
body: list[stmt]
47-
if sys.version_info >= (3, 8):
48-
type_ignores: list[TypeIgnore]
42+
type_ignores: list[TypeIgnore]
4943

5044
class Interactive(mod):
5145
if sys.version_info >= (3, 10):
@@ -340,21 +334,6 @@ class JoinedStr(expr):
340334
__match_args__ = ("values",)
341335
values: list[expr]
342336

343-
if sys.version_info < (3, 8):
344-
class Num(expr): # Deprecated in 3.8; use Constant
345-
n: int | float | complex
346-
347-
class Str(expr): # Deprecated in 3.8; use Constant
348-
s: str
349-
350-
class Bytes(expr): # Deprecated in 3.8; use Constant
351-
s: bytes
352-
353-
class NameConstant(expr): # Deprecated in 3.8; use Constant
354-
value: Any
355-
356-
class Ellipsis(expr): ... # Deprecated in 3.8; use Constant
357-
358337
class Constant(expr):
359338
if sys.version_info >= (3, 10):
360339
__match_args__ = ("value", "kind")
@@ -364,12 +343,11 @@ class Constant(expr):
364343
s: Any
365344
n: int | float | complex
366345

367-
if sys.version_info >= (3, 8):
368-
class NamedExpr(expr):
369-
if sys.version_info >= (3, 10):
370-
__match_args__ = ("target", "value")
371-
target: Name
372-
value: expr
346+
class NamedExpr(expr):
347+
if sys.version_info >= (3, 10):
348+
__match_args__ = ("target", "value")
349+
target: Name
350+
value: expr
373351

374352
class Attribute(expr):
375353
if sys.version_info >= (3, 10):
@@ -498,8 +476,7 @@ class ExceptHandler(excepthandler):
498476
class arguments(AST):
499477
if sys.version_info >= (3, 10):
500478
__match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults")
501-
if sys.version_info >= (3, 8):
502-
posonlyargs: list[arg]
479+
posonlyargs: list[arg]
503480
args: list[arg]
504481
vararg: arg | None
505482
kwonlyargs: list[arg]

mypy/typeshed/stdlib/_codecs.pyi

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import codecs
22
import sys
33
from _typeshed import ReadableBuffer
44
from collections.abc import Callable
5-
from typing import overload
6-
from typing_extensions import Literal, TypeAlias
5+
from typing import Literal, overload
6+
from typing_extensions import TypeAlias
77

88
# This type is not exposed; it is defined in unicodeobject.c
99
class _EncodingMap:
@@ -99,11 +99,6 @@ else:
9999
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
100100

101101
def unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
102-
103-
if sys.version_info < (3, 8):
104-
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
105-
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...
106-
107102
def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
108103
def utf_16_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
109104
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ from typing import ( # noqa: Y022,Y038,Y057
3030
Sized as Sized,
3131
TypeVar,
3232
ValuesView as ValuesView,
33+
final,
3334
runtime_checkable,
3435
)
35-
from typing_extensions import final
3636

3737
__all__ = [
3838
"Awaitable",

mypy/typeshed/stdlib/_csv.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import sys
22
from _typeshed import SupportsWrite
33
from collections.abc import Iterable, Iterator
4-
from typing import Any
5-
from typing_extensions import Final, Literal, TypeAlias
4+
from typing import Any, Final, Literal
5+
from typing_extensions import TypeAlias
66

77
__version__: Final[str]
88

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import ReadableBuffer, WriteableBuffer
33
from abc import abstractmethod
44
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
5-
from ctypes import CDLL
5+
from ctypes import CDLL, ArgumentError as ArgumentError
66
from typing import Any, ClassVar, Generic, TypeVar, overload
77
from typing_extensions import Self, TypeAlias
88

@@ -197,8 +197,6 @@ class Array(_CData, Generic[_CT]):
197197
if sys.version_info >= (3, 9):
198198
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
199199

200-
class ArgumentError(Exception): ...
201-
202200
def addressof(obj: _CData) -> int: ...
203201
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
204202
def get_errno() -> int: ...

mypy/typeshed/stdlib/_curses.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import ReadOnlyBuffer, SupportsRead
3-
from typing import IO, Any, NamedTuple, overload
4-
from typing_extensions import TypeAlias, final
3+
from typing import IO, Any, NamedTuple, final, overload
4+
from typing_extensions import TypeAlias
55

66
if sys.platform != "win32":
77
# Handled by PyCurses_ConvertToChtype in _cursesmodule.c.
@@ -548,10 +548,10 @@ if sys.platform != "win32":
548548
def vline(self, ch: _ChType, n: int) -> None: ...
549549
@overload
550550
def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
551-
if sys.version_info >= (3, 8):
552-
class _ncurses_version(NamedTuple):
553-
major: int
554-
minor: int
555-
patch: int
556-
ncurses_version: _ncurses_version
557-
window = _CursesWindow # undocumented
551+
552+
class _ncurses_version(NamedTuple):
553+
major: int
554+
minor: int
555+
patch: int
556+
ncurses_version: _ncurses_version
557+
window = _CursesWindow # undocumented

mypy/typeshed/stdlib/_decimal.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import numbers
22
import sys
33
from collections.abc import Container, Sequence
44
from types import TracebackType
5-
from typing import Any, ClassVar, NamedTuple, overload
6-
from typing_extensions import Final, Literal, Self, TypeAlias
5+
from typing import Any, ClassVar, Final, Literal, NamedTuple, overload
6+
from typing_extensions import Self, TypeAlias
77

88
_Decimal: TypeAlias = Decimal | int
99
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]

mypy/typeshed/stdlib/_dummy_threading.pyi

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from _thread import _excepthook, _ExceptHookArgs
23
from _typeshed import ProfileFunction, TraceFunction
34
from collections.abc import Callable, Iterable, Mapping
45
from types import TracebackType
@@ -28,11 +29,10 @@ __all__ = [
2829
"settrace",
2930
"local",
3031
"stack_size",
32+
"ExceptHookArgs",
33+
"excepthook",
3134
]
3235

33-
if sys.version_info >= (3, 8):
34-
__all__ += ["ExceptHookArgs", "excepthook"]
35-
3636
def active_count() -> int: ...
3737
def current_thread() -> Thread: ...
3838
def currentThread() -> Thread: ...
@@ -72,10 +72,8 @@ class Thread:
7272
def join(self, timeout: float | None = None) -> None: ...
7373
def getName(self) -> str: ...
7474
def setName(self, name: str) -> None: ...
75-
if sys.version_info >= (3, 8):
76-
@property
77-
def native_id(self) -> int | None: ... # only available on some platforms
78-
75+
@property
76+
def native_id(self) -> int | None: ... # only available on some platforms
7977
def is_alive(self) -> bool: ...
8078
if sys.version_info < (3, 9):
8179
def isAlive(self) -> bool: ...
@@ -138,11 +136,8 @@ class Event:
138136
def clear(self) -> None: ...
139137
def wait(self, timeout: float | None = None) -> bool: ...
140138

141-
if sys.version_info >= (3, 8):
142-
from _thread import _excepthook, _ExceptHookArgs
143-
144-
excepthook = _excepthook
145-
ExceptHookArgs = _ExceptHookArgs
139+
excepthook = _excepthook
140+
ExceptHookArgs = _ExceptHookArgs
146141

147142
class Timer(Thread):
148143
def __init__(

mypy/typeshed/stdlib/_heapq.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from typing import Any, TypeVar
2-
from typing_extensions import Final
1+
from typing import Any, Final, TypeVar
32

43
_T = TypeVar("_T")
54

mypy/typeshed/stdlib/_json.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections.abc import Callable
2-
from typing import Any
3-
from typing_extensions import final
2+
from typing import Any, final
43

54
@final
65
class make_encoder:

mypy/typeshed/stdlib/_operator.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import sys
22
from _typeshed import SupportsGetItem
33
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
4-
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, TypeVar, overload
5-
from typing_extensions import ParamSpec, SupportsIndex, TypeAlias, TypeVarTuple, Unpack, final
4+
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, SupportsIndex, TypeVar, final, overload
5+
from typing_extensions import ParamSpec, TypeAlias, TypeVarTuple, Unpack
66

77
_R = TypeVar("_R")
88
_T = TypeVar("_T")

mypy/typeshed/stdlib/_osx_support.pyi

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from collections.abc import Iterable, Sequence
32
from typing import TypeVar
43

@@ -13,13 +12,7 @@ _COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
1312
_INITPRE: str # undocumented
1413

1514
def _find_executable(executable: str, path: str | None = None) -> str | None: ... # undocumented
16-
17-
if sys.version_info >= (3, 8):
18-
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented
19-
20-
else:
21-
def _read_output(commandstring: str) -> str | None: ... # undocumented
22-
15+
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented
2316
def _find_build_tool(toolname: str) -> str: ... # undocumented
2417

2518
_SYSTEM_VERSION: str | None # undocumented

mypy/typeshed/stdlib/_posixsubprocess.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import StrOrBytesPath
33
from collections.abc import Callable, Sequence
4-
from typing_extensions import SupportsIndex
4+
from typing import SupportsIndex
55

66
if sys.platform != "win32":
77
def cloexec_pipe() -> tuple[int, int]: ...

mypy/typeshed/stdlib/_sitebuiltins.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections.abc import Iterable
2-
from typing import ClassVar, NoReturn
3-
from typing_extensions import Literal
2+
from typing import ClassVar, Literal, NoReturn
43

54
class Quitter:
65
name: str

0 commit comments

Comments
 (0)