Skip to content

Commit 40bbfb5

Browse files
authored
Sync typeshed (#12663)
* Sync typeshed Source commit: python/typeshed@5dad506 * Fix tests Co-authored-by: hauntsaninja <>
1 parent d1c0616 commit 40bbfb5

File tree

289 files changed

+2086
-1454
lines changed

Some content is hidden

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

289 files changed

+2086
-1454
lines changed

mypy/test/teststubtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ def test_config_file(self) -> None:
11741174
output = run_stubtest(stub=stub, runtime=runtime, options=[])
11751175
assert remove_color_code(output) == (
11761176
"error: test_module.temp variable differs from runtime type Literal[5]\n"
1177-
"Stub: at line 2\ndecimal.Decimal\nRuntime:\n5\n\n"
1177+
"Stub: at line 2\n_decimal.Decimal\nRuntime:\n5\n\n"
11781178
)
11791179
output = run_stubtest(stub=stub, runtime=runtime, options=[], config_file=config_file)
11801180
assert output == ""

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ webbrowser: 2.7-
286286
winreg: 3.0-
287287
winsound: 2.7-
288288
wsgiref: 2.7-
289+
wsgiref.types: 3.11-
289290
xdrlib: 2.7-
290291
xml: 2.7-
291292
xmlrpc: 3.0-

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import sys
22
from typing import Any, ClassVar
3-
from typing_extensions import Literal
3+
from typing_extensions import Literal, TypeAlias
44

55
PyCF_ONLY_AST: Literal[1024]
66
if sys.version_info >= (3, 8):
77
PyCF_TYPE_COMMENTS: Literal[4096]
88
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
99

10-
_identifier = str
10+
_identifier: TypeAlias = str
1111

1212
class AST:
1313
if sys.version_info >= (3, 10):
@@ -172,6 +172,14 @@ class Try(stmt):
172172
orelse: list[stmt]
173173
finalbody: list[stmt]
174174

175+
if sys.version_info >= (3, 11):
176+
class TryStar(stmt):
177+
__match_args__ = ("body", "handlers", "orelse", "finalbody")
178+
body: list[stmt]
179+
handlers: list[ExceptHandler]
180+
orelse: list[stmt]
181+
finalbody: list[stmt]
182+
175183
class Assert(stmt):
176184
if sys.version_info >= (3, 10):
177185
__match_args__ = ("test", "msg")
@@ -358,10 +366,10 @@ class Attribute(expr):
358366
ctx: expr_context
359367

360368
if sys.version_info >= (3, 9):
361-
_SliceT = expr
369+
_SliceT: TypeAlias = expr
362370
else:
363371
class slice(AST): ...
364-
_SliceT = slice
372+
_SliceT: TypeAlias = slice
365373

366374
class Slice(_SliceT):
367375
if sys.version_info >= (3, 10):
@@ -516,7 +524,7 @@ if sys.version_info >= (3, 10):
516524

517525
class pattern(AST): ...
518526
# Without the alias, Pyright complains variables named pattern are recursively defined
519-
_pattern = pattern
527+
_pattern: TypeAlias = pattern
520528

521529
class match_case(AST):
522530
__match_args__ = ("pattern", "guard", "body")

mypy/typeshed/stdlib/_bisect.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import SupportsRichComparisonT
3-
from typing import Callable, MutableSequence, Sequence, TypeVar, overload
3+
from collections.abc import Callable, MutableSequence, Sequence
4+
from typing import TypeVar, overload
45

56
_T = TypeVar("_T")
67

mypy/typeshed/stdlib/_codecs.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import codecs
22
import sys
3-
from typing import Any, Callable
3+
from collections.abc import Callable
4+
from typing import Any
5+
from typing_extensions import TypeAlias
46

57
# This type is not exposed; it is defined in unicodeobject.c
68
class _EncodingMap:
79
def size(self) -> int: ...
810

9-
_MapT = dict[int, int] | _EncodingMap
10-
_Handler = Callable[[Exception], tuple[str, int]]
11+
_MapT: TypeAlias = dict[int, int] | _EncodingMap
12+
_Handler: TypeAlias = Callable[[Exception], tuple[str, int]]
1113

1214
def register(__search_function: Callable[[str], Any]) -> None: ...
1315
def register_error(__errors: str, __handler: _Handler) -> None: ...

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from types import MappingProxyType
3-
from typing import (
3+
from typing import ( # noqa: Y027,Y038
44
AbstractSet as Set,
55
AsyncGenerator as AsyncGenerator,
66
AsyncIterable as AsyncIterable,

mypy/typeshed/stdlib/_compression.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from _typeshed import WriteableBuffer
2+
from collections.abc import Callable
23
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
3-
from typing import Any, Callable, Protocol
4+
from typing import Any, Protocol
45

56
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
67

mypy/typeshed/stdlib/_csv.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from typing import Any, Iterable, Iterator, Protocol, Union
2-
from typing_extensions import Literal
1+
from collections.abc import Iterable, Iterator
2+
from typing import Any, Protocol, Union
3+
from typing_extensions import Literal, TypeAlias
34

45
__version__: str
56

@@ -21,7 +22,7 @@ class Dialect:
2122
strict: int
2223
def __init__(self) -> None: ...
2324

24-
_DialectLike = Union[str, Dialect, type[Dialect]]
25+
_DialectLike: TypeAlias = Union[str, Dialect, type[Dialect]]
2526

2627
class _reader(Iterator[list[str]]):
2728
dialect: Dialect

mypy/typeshed/stdlib/_curses.pyi

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

66
if sys.platform != "win32":
7-
_chtype = str | bytes | int
7+
_chtype: TypeAlias = str | bytes | int
88

99
# ACS codes are only initialized after initscr is called
1010
ACS_BBSS: int

0 commit comments

Comments
 (0)