Skip to content

Commit 12371f1

Browse files
committed
Merge remote-tracking branch 'upstream/main' into python315
# Conflicts: # stdlib/_interpqueues.pyi # stdlib/ast.pyi # stdlib/base64.pyi # stdlib/collections/__init__.pyi # stdlib/glob.pyi # stdlib/importlib/metadata/__init__.pyi # stdlib/pyexpat/__init__.pyi # stdlib/sys/__init__.pyi # stdlib/threading.pyi # stdlib/types.pyi # stdlib/typing.pyi # stdlib/unicodedata.pyi # stdlib/unittest/_log.pyi # stdlib/unittest/case.pyi # stdlib/wave.pyi # stdlib/zipimport.pyi
2 parents 16fbcb9 + a7f0a82 commit 12371f1

721 files changed

Lines changed: 2662 additions & 5419 deletions

File tree

Some content is hidden

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

lib/ts_utils/metadata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
from collections.abc import Mapping
1414
from dataclasses import dataclass
1515
from pathlib import Path
16-
from typing import Annotated, Any, Final, NamedTuple, cast, final
17-
from typing_extensions import TypeGuard
16+
from typing import Annotated, Any, Final, NamedTuple, TypeGuard, cast, final
1817

1918
if sys.version_info >= (3, 11):
2019
import tomllib

lib/ts_utils/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from collections.abc import Iterable, Mapping
1010
from pathlib import Path
1111
from types import MethodType
12-
from typing import TYPE_CHECKING, Any, Final, NamedTuple
13-
from typing_extensions import TypeAlias
12+
from typing import TYPE_CHECKING, Any, Final, NamedTuple, TypeAlias
1413

1514
import pathspec
1615
from packaging.requirements import Requirement

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ select = [
106106
"PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics
107107
"PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`.
108108
"PYI058", # Use `{return_type}` as the return value for simple `{method}` methods
109-
# "PYI059", # TODO: Add when dropping Python 3.9 support
109+
"PYI059", # Checks for classes inheriting from typing.Generic[] where Generic[] is not the last base class in the bases tuple
110110
"PYI061", # Use `None` rather than `Literal[None]`
111111
"PYI062", # Duplicate literal member `{}`
112112
"PYI064", # `Final[Literal[{literal}]]` can be replaced with a bare Final

scripts/stubsabot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
from dataclasses import dataclass, field
2323
from http import HTTPStatus
2424
from pathlib import Path
25-
from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypedDict, TypeVar
26-
from typing_extensions import Self, TypeAlias
25+
from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar
26+
from typing_extensions import Self
2727

2828
if sys.version_info >= (3, 11):
2929
import tomllib

stdlib/@tests/test_cases/check_functools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

33
from functools import cache, cached_property, lru_cache, wraps
4-
from typing import Callable, TypeVar
5-
from typing_extensions import ParamSpec, assert_type
4+
from typing import Callable, ParamSpec, TypeVar
5+
from typing_extensions import assert_type
66

77
P = ParamSpec("P")
88
T_co = TypeVar("T_co", covariant=True)
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
from __future__ import annotations
22

3-
import sys
43
from _typeshed import StrPath
4+
from importlib.metadata._meta import SimplePath
55
from os import PathLike
66
from pathlib import Path
77
from zipfile import Path as ZipPath
88

9-
if sys.version_info >= (3, 10):
10-
from importlib.metadata._meta import SimplePath
119

12-
# Simplified version of zipfile.Path
13-
class MyPath:
14-
@property
15-
def parent(self) -> PathLike[str]: ... # undocumented
10+
# Simplified version of zipfile.Path
11+
class MyPath:
12+
@property
13+
def parent(self) -> PathLike[str]: ... # undocumented
1614

17-
def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ...
18-
def read_bytes(self) -> bytes: ...
19-
def joinpath(self, *other: StrPath) -> MyPath: ...
20-
def __truediv__(self, add: StrPath) -> MyPath: ...
21-
def exists(self) -> bool: ...
15+
def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ...
16+
def read_bytes(self) -> bytes: ...
17+
def joinpath(self, *other: StrPath) -> MyPath: ...
18+
def __truediv__(self, add: StrPath) -> MyPath: ...
19+
def exists(self) -> bool: ...
2220

23-
def takes_simple_path(p: SimplePath) -> None: ...
2421

25-
takes_simple_path(Path())
26-
takes_simple_path(ZipPath(""))
27-
takes_simple_path(MyPath())
28-
takes_simple_path("some string") # type: ignore
22+
def takes_simple_path(p: SimplePath) -> None: ...
23+
24+
25+
takes_simple_path(Path())
26+
takes_simple_path(ZipPath(""))
27+
takes_simple_path(MyPath())
28+
takes_simple_path("some string") # type: ignore

stdlib/@tests/test_cases/check_types.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,15 @@ def foo(self) -> None:
6565
# check that NotImplemented is treated as an "Any"
6666
x: int = NotImplemented
6767

68-
if sys.version_info >= (3, 10):
69-
# test NotImplementedType usage
70-
assert_type(NotImplemented, types.NotImplementedType)
71-
assert_type(types.NotImplementedType(), types.NotImplementedType)
72-
# test EllipsisType usage
73-
assert_type(Ellipsis, types.EllipsisType)
74-
assert_type(types.EllipsisType(), types.EllipsisType)
75-
# test NoneType usage (disabled, passes with pyright, but mypy errors
76-
# assert_type(None, types.NoneType)
77-
# assert_type(types.NoneType(), types.NoneType)
68+
# test NotImplementedType usage
69+
assert_type(NotImplemented, types.NotImplementedType)
70+
assert_type(types.NotImplementedType(), types.NotImplementedType)
71+
# test EllipsisType usage
72+
assert_type(Ellipsis, types.EllipsisType)
73+
assert_type(types.EllipsisType(), types.EllipsisType)
74+
# test NoneType usage (disabled, passes with pyright, but mypy errors
75+
# assert_type(None, types.NoneType)
76+
# assert_type(types.NoneType(), types.NoneType)
7877

7978
if sys.version_info >= (3, 11):
8079
union_type = int | list[_T]

stdlib/@tests/test_cases/itertools/check_itertools_recipes.py

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
Sequence,
2323
Tuple,
2424
Type,
25+
TypeAlias,
2526
TypeVar,
2627
Union,
2728
overload,
2829
)
29-
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
30+
from typing_extensions import TypeVarTuple, Unpack
3031

3132
_T = TypeVar("_T")
3233
_T1 = TypeVar("_T1")
@@ -326,44 +327,46 @@ def nth_combination(iterable: Iterable[_T], r: int, index: int) -> tuple[_T, ...
326327
return tuple(result)
327328

328329

329-
if sys.version_info >= (3, 10):
330-
331-
@overload
332-
def grouper(
333-
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None
334-
) -> Iterator[tuple[_T | None, ...]]: ...
335-
336-
@overload
337-
def grouper(
338-
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1
339-
) -> Iterator[tuple[_T | _T1, ...]]: ...
340-
341-
@overload
342-
def grouper(
343-
iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None
344-
) -> Iterator[tuple[_T, ...]]: ...
345-
346-
def grouper(
347-
iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None
348-
) -> Iterator[tuple[object, ...]]:
349-
"Collect data into non-overlapping fixed-length chunks or blocks"
350-
# grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx
351-
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
352-
# grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF
353-
args = [iter(iterable)] * n
354-
if incomplete == "fill":
355-
return zip_longest(*args, fillvalue=fillvalue)
356-
if incomplete == "strict":
357-
return zip(*args, strict=True)
358-
if incomplete == "ignore":
359-
return zip(*args)
360-
else:
361-
raise ValueError("Expected fill, strict, or ignore")
362-
363-
def transpose(it: Iterable[Iterable[_T]]) -> Iterator[tuple[_T, ...]]:
364-
"Swap the rows and columns of the input."
365-
# transpose([(1, 2, 3), (11, 22, 33)]) --> (1, 11) (2, 22) (3, 33)
366-
return zip(*it, strict=True)
330+
@overload
331+
def grouper(
332+
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None
333+
) -> Iterator[tuple[_T | None, ...]]: ...
334+
335+
336+
@overload
337+
def grouper(
338+
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1
339+
) -> Iterator[tuple[_T | _T1, ...]]: ...
340+
341+
342+
@overload
343+
def grouper(
344+
iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None
345+
) -> Iterator[tuple[_T, ...]]: ...
346+
347+
348+
def grouper(
349+
iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None
350+
) -> Iterator[tuple[object, ...]]:
351+
"Collect data into non-overlapping fixed-length chunks or blocks"
352+
# grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx
353+
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
354+
# grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF
355+
args = [iter(iterable)] * n
356+
if incomplete == "fill":
357+
return zip_longest(*args, fillvalue=fillvalue)
358+
if incomplete == "strict":
359+
return zip(*args, strict=True)
360+
if incomplete == "ignore":
361+
return zip(*args)
362+
else:
363+
raise ValueError("Expected fill, strict, or ignore")
364+
365+
366+
def transpose(it: Iterable[Iterable[_T]]) -> Iterator[tuple[_T, ...]]:
367+
"Swap the rows and columns of the input."
368+
# transpose([(1, 2, 3), (11, 22, 33)]) --> (1, 11) (2, 22) (3, 33)
369+
return zip(*it, strict=True)
367370

368371

369372
if sys.version_info >= (3, 12):

stdlib/VERSIONS

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ _ast: 3.0-
2323
_asyncio: 3.0-
2424
_bisect: 3.0-
2525
_blake2: 3.6-
26-
_bootlocale: 3.4-3.9
2726
_bz2: 3.3-
2827
_codecs: 3.0-
2928
_collections_abc: 3.3-
@@ -143,7 +142,6 @@ difflib: 3.0-
143142
dis: 3.0-
144143
distutils: 3.0-3.11
145144
distutils.command.bdist_msi: 3.0-3.10
146-
distutils.command.bdist_wininst: 3.0-3.9
147145
doctest: 3.0-
148146
email: 3.0-
149147
encodings: 3.0-
@@ -160,7 +158,6 @@ fcntl: 3.0-
160158
filecmp: 3.0-
161159
fileinput: 3.0-
162160
fnmatch: 3.0-
163-
formatter: 3.0-3.9
164161
fractions: 3.0-
165162
ftplib: 3.0-
166163
functools: 3.0-
@@ -232,7 +229,6 @@ operator: 3.0-
232229
optparse: 3.0-
233230
os: 3.0-
234231
ossaudiodev: 3.0-3.12
235-
parser: 3.0-3.9
236232
pathlib: 3.4-
237233
pathlib.types: 3.14-
238234
pdb: 3.0-
@@ -296,7 +292,6 @@ stringprep: 3.0-
296292
struct: 3.0-
297293
subprocess: 3.0-
298294
sunau: 3.0-3.12
299-
symbol: 3.0-3.9
300295
symtable: 3.0-
301296
sys: 3.0-
302297
sys.__jit: 3.14- # Similar to sys._monitoring

stdlib/__future__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing_extensions import TypeAlias
1+
from typing import TypeAlias
22

33
_VersionInfo: TypeAlias = tuple[int, int, int, str, int]
44

0 commit comments

Comments
 (0)