Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into te-imports
  • Loading branch information
srittau committed May 7, 2026
commit 4d6e2696853385516c269879bf5a5e2629504b66
34 changes: 17 additions & 17 deletions stdlib/@tests/test_cases/check_importlib_metadata.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
from __future__ import annotations

import sys
from _typeshed import StrPath
from importlib.metadata._meta import SimplePath
from os import PathLike
from pathlib import Path
from zipfile import Path as ZipPath

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

# Simplified version of zipfile.Path
class MyPath:
@property
def parent(self) -> PathLike[str]: ... # undocumented
# Simplified version of zipfile.Path
class MyPath:
@property
def parent(self) -> PathLike[str]: ... # undocumented

def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ...
def read_bytes(self) -> bytes: ...
def joinpath(self, *other: StrPath) -> MyPath: ...
def __truediv__(self, add: StrPath) -> MyPath: ...
def exists(self) -> bool: ...
def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ...
def read_bytes(self) -> bytes: ...
def joinpath(self, *other: StrPath) -> MyPath: ...
def __truediv__(self, add: StrPath) -> MyPath: ...
def exists(self) -> bool: ...

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

takes_simple_path(Path())
takes_simple_path(ZipPath(""))
takes_simple_path(MyPath())
takes_simple_path("some string") # type: ignore
def takes_simple_path(p: SimplePath) -> None: ...


takes_simple_path(Path())
takes_simple_path(ZipPath(""))
takes_simple_path(MyPath())
takes_simple_path("some string") # type: ignore
19 changes: 9 additions & 10 deletions stdlib/@tests/test_cases/check_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ def foo(self) -> None:
# check that NotImplemented is treated as an "Any"
x: int = NotImplemented

if sys.version_info >= (3, 10):
# test NotImplementedType usage
assert_type(NotImplemented, types.NotImplementedType)
assert_type(types.NotImplementedType(), types.NotImplementedType)
# test EllipsisType usage
assert_type(Ellipsis, types.EllipsisType)
assert_type(types.EllipsisType(), types.EllipsisType)
# test NoneType usage (disabled, passes with pyright, but mypy errors
# assert_type(None, types.NoneType)
# assert_type(types.NoneType(), types.NoneType)
# test NotImplementedType usage
assert_type(NotImplemented, types.NotImplementedType)
assert_type(types.NotImplementedType(), types.NotImplementedType)
# test EllipsisType usage
assert_type(Ellipsis, types.EllipsisType)
assert_type(types.EllipsisType(), types.EllipsisType)
# test NoneType usage (disabled, passes with pyright, but mypy errors
# assert_type(None, types.NoneType)
# assert_type(types.NoneType(), types.NoneType)

if sys.version_info >= (3, 11):
union_type = int | list[_T]
Expand Down
78 changes: 40 additions & 38 deletions stdlib/@tests/test_cases/itertools/check_itertools_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,44 +327,46 @@ def nth_combination(iterable: Iterable[_T], r: int, index: int) -> tuple[_T, ...
return tuple(result)


if sys.version_info >= (3, 10):

@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None
) -> Iterator[tuple[_T | None, ...]]: ...

@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1
) -> Iterator[tuple[_T | _T1, ...]]: ...

@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None
) -> Iterator[tuple[_T, ...]]: ...

def grouper(
iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None
) -> Iterator[tuple[object, ...]]:
"Collect data into non-overlapping fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
# grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF
args = [iter(iterable)] * n
if incomplete == "fill":
return zip_longest(*args, fillvalue=fillvalue)
if incomplete == "strict":
return zip(*args, strict=True)
if incomplete == "ignore":
return zip(*args)
else:
raise ValueError("Expected fill, strict, or ignore")

def transpose(it: Iterable[Iterable[_T]]) -> Iterator[tuple[_T, ...]]:
"Swap the rows and columns of the input."
# transpose([(1, 2, 3), (11, 22, 33)]) --> (1, 11) (2, 22) (3, 33)
return zip(*it, strict=True)
@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None
) -> Iterator[tuple[_T | None, ...]]: ...


@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1
) -> Iterator[tuple[_T | _T1, ...]]: ...


@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None
) -> Iterator[tuple[_T, ...]]: ...


def grouper(
iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None
) -> Iterator[tuple[object, ...]]:
"Collect data into non-overlapping fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
# grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF
args = [iter(iterable)] * n
if incomplete == "fill":
return zip_longest(*args, fillvalue=fillvalue)
if incomplete == "strict":
return zip(*args, strict=True)
if incomplete == "ignore":
return zip(*args)
else:
raise ValueError("Expected fill, strict, or ignore")


def transpose(it: Iterable[Iterable[_T]]) -> Iterator[tuple[_T, ...]]:
"Swap the rows and columns of the input."
# transpose([(1, 2, 3), (11, 22, 33)]) --> (1, 11) (2, 22) (3, 33)
return zip(*it, strict=True)


if sys.version_info >= (3, 12):
Expand Down
5 changes: 0 additions & 5 deletions stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ _ast: 3.0-
_asyncio: 3.0-
_bisect: 3.0-
_blake2: 3.6-
_bootlocale: 3.4-3.9
_bz2: 3.3-
_codecs: 3.0-
_collections_abc: 3.3-
Expand Down Expand Up @@ -143,7 +142,6 @@ difflib: 3.0-
dis: 3.0-
distutils: 3.0-3.11
distutils.command.bdist_msi: 3.0-3.10
distutils.command.bdist_wininst: 3.0-3.9
doctest: 3.0-
email: 3.0-
encodings: 3.0-
Expand All @@ -160,7 +158,6 @@ fcntl: 3.0-
filecmp: 3.0-
fileinput: 3.0-
fnmatch: 3.0-
formatter: 3.0-3.9
fractions: 3.0-
ftplib: 3.0-
functools: 3.0-
Expand Down Expand Up @@ -231,7 +228,6 @@ operator: 3.0-
optparse: 3.0-
os: 3.0-
ossaudiodev: 3.0-3.12
parser: 3.0-3.9
pathlib: 3.4-
pathlib.types: 3.14-
pdb: 3.0-
Expand Down Expand Up @@ -292,7 +288,6 @@ stringprep: 3.0-
struct: 3.0-
subprocess: 3.0-
sunau: 3.0-3.12
symbol: 3.0-3.9
symtable: 3.0-
sys: 3.0-
sys.__jit: 3.14- # Similar to sys._monitoring
Expand Down
26 changes: 11 additions & 15 deletions stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ from ast import (
LShift as LShift,
Lt as Lt,
LtE as LtE,
Match as Match,
MatchAs as MatchAs,
MatchClass as MatchClass,
MatchMapping as MatchMapping,
MatchOr as MatchOr,
MatchSequence as MatchSequence,
MatchSingleton as MatchSingleton,
MatchStar as MatchStar,
MatchValue as MatchValue,
MatMult as MatMult,
Mod as Mod,
Module as Module,
Expand Down Expand Up @@ -101,8 +110,10 @@ from ast import (
expr as expr,
expr_context as expr_context,
keyword as keyword,
match_case as match_case,
mod as mod,
operator as operator,
pattern as pattern,
stmt as stmt,
type_ignore as type_ignore,
unaryop as unaryop,
Expand All @@ -122,21 +133,6 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 11):
from ast import TryStar as TryStar

if sys.version_info >= (3, 10):
from ast import (
Match as Match,
MatchAs as MatchAs,
MatchClass as MatchClass,
MatchMapping as MatchMapping,
MatchOr as MatchOr,
MatchSequence as MatchSequence,
MatchSingleton as MatchSingleton,
MatchStar as MatchStar,
MatchValue as MatchValue,
match_case as match_case,
pattern as pattern,
)

PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192
PyCF_ONLY_AST: Final = 1024
PyCF_TYPE_COMMENTS: Final = 4096
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.