Skip to content

Commit c2214bb

Browse files
committed
Merge branch 'main' into structured-obsolete-since
2 parents 7d676be + b249a9d commit c2214bb

778 files changed

Lines changed: 3772 additions & 5815 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.

.github/workflows/daily.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
matrix:
3737
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
3838
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
39+
exclude:
40+
# https://github.com/python/typeshed/issues/15694
41+
- os: "windows-latest"
42+
python-version: "3.10"
3943
fail-fast: false
4044

4145
steps:

.github/workflows/stubtest_stdlib.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
matrix:
3333
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
3434
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
35+
exclude:
36+
# https://github.com/python/typeshed/issues/15694
37+
- os: "windows-latest"
38+
python-version: "3.10"
3539
fail-fast: false
3640

3741
steps:

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, cast
26-
from typing_extensions import Self, TypeAlias
25+
from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar, cast
26+
from typing_extensions import Self
2727

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

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ importlib.metadata.DeprecatedNonAbstract.__new__
132132
importlib.resources._common.files
133133

134134
sys._monitoring # Doesn't really exist. See comments in the stub.
135+
sys.__jit # Similar to sys._monitoring
135136
sys.last_exc # not always defined
136137

137138
# These only exist to give a better error message if you try to subclass an instance

stdlib/@tests/test_cases/check_functools.py

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from __future__ import annotations
22

3-
from functools import cache, cached_property, wraps
4-
from typing import Callable, TypeVar
5-
from typing_extensions import ParamSpec, assert_type
3+
from functools import cache, cached_property, lru_cache, wraps
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)
99

10+
#
11+
# Tests for @wraps
12+
#
13+
1014

1115
def my_decorator(func: Callable[P, T_co]) -> Callable[P, T_co]:
1216
@wraps(func)
@@ -54,6 +58,57 @@ def func_wrapper(x: int) -> None: ...
5458
func_wrapper(3)
5559

5660

61+
#
62+
# Tests for @cache
63+
#
64+
65+
66+
@cache
67+
def check_cache(x: int) -> int:
68+
return x * 2
69+
70+
71+
assert_type(check_cache(3), int)
72+
# Type checkers should check the argument type, but this is currently not
73+
# possible. See https://github.com/python/typeshed/issues/6347 and
74+
# https://github.com/python/typeshed/issues/11280.
75+
# check_cached("invalid") # xtype: ignore
76+
77+
assert_type(check_cache.cache_info().misses, int)
78+
79+
80+
#
81+
# Tests for @lru_cache
82+
#
83+
84+
85+
@lru_cache
86+
def check_lru_cache(x: int) -> int:
87+
return x * 2
88+
89+
90+
@lru_cache(maxsize=32)
91+
def check_lru_cache_with_maxsize(x: int) -> int:
92+
return x * 2
93+
94+
95+
assert_type(check_lru_cache(3), int)
96+
assert_type(check_lru_cache_with_maxsize(3), int)
97+
# Type checkers should check the argument type, but this is currently not
98+
# possible. See https://github.com/python/typeshed/issues/6347 and
99+
# https://github.com/python/typeshed/issues/11280.
100+
# check_lru_cache("invalid") # xtype: ignore
101+
# check_lru_cache_with_maxsize("invalid") # xtype: ignore
102+
103+
assert_type(check_lru_cache.cache_info().misses, int)
104+
assert_type(check_lru_cache_with_maxsize.cache_info().misses, int)
105+
106+
107+
#
108+
# Tests for @cached_property
109+
#
110+
111+
57112
class A:
58113
def __init__(self, x: int):
59114
self.x = x
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_io.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
from _io import BufferedReader
1+
from _io import BufferedReader, BufferedRWPair, BufferedWriter
22
from gzip import GzipFile
33
from io import FileIO, RawIOBase, TextIOWrapper
4+
from socket import SocketIO
5+
from typing import Any
46
from typing_extensions import assert_type
57

8+
socket: Any = None
9+
610
BufferedReader(RawIOBase())
11+
BufferedWriter(RawIOBase())
12+
BufferedWriter(SocketIO(socket, "r"))
13+
14+
BufferedRWPair(open("", "rb"), open("", "wb"))
715

816
assert_type(TextIOWrapper(FileIO("")).buffer, FileIO)
917
assert_type(TextIOWrapper(FileIO(13)).detach(), FileIO)

0 commit comments

Comments
 (0)