Skip to content

Commit f16b520

Browse files
Merge branch 'python:main' into list_signatures
2 parents 0f25cae + 35004e9 commit f16b520

File tree

12 files changed

+252
-22
lines changed

12 files changed

+252
-22
lines changed

stdlib/@tests/test_cases/builtins/check_set.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,46 @@ def test_set_difference(x: set[Literal["foo", "bar"]], y: set[str], z: set[int])
1212
assert_type(z - x, set[int])
1313
assert_type(y - z, set[str])
1414
assert_type(z - y, set[int])
15+
16+
17+
def test_set_interface_overlapping_type(s: set[Literal["foo", "bar"]], y: set[str], key: str) -> None:
18+
s.add(key) # type: ignore
19+
s.discard(key)
20+
s.remove(key) # type: ignore
21+
s.difference_update(y)
22+
s.intersection_update(y)
23+
s.symmetric_difference_update(y) # type: ignore
24+
s.update(y) # type: ignore
25+
26+
assert_type(s.difference(y), set[Literal["foo", "bar"]])
27+
assert_type(s.intersection(y), set[Literal["foo", "bar"]])
28+
assert_type(s.isdisjoint(y), bool)
29+
assert_type(s.issubset(y), bool)
30+
assert_type(s.issuperset(y), bool)
31+
assert_type(s.symmetric_difference(y), set[str])
32+
assert_type(s.union(y), set[str])
33+
34+
assert_type(s - y, set[Literal["foo", "bar"]])
35+
assert_type(s & y, set[Literal["foo", "bar"]])
36+
assert_type(s | y, set[str])
37+
assert_type(s ^ y, set[str])
38+
39+
s -= y
40+
s &= y
41+
s |= y # type: ignore
42+
s ^= y # type: ignore
43+
44+
45+
def test_frozenset_interface(s: frozenset[Literal["foo", "bar"]], y: frozenset[str]) -> None:
46+
assert_type(s.difference(y), frozenset[Literal["foo", "bar"]])
47+
assert_type(s.intersection(y), frozenset[Literal["foo", "bar"]])
48+
assert_type(s.isdisjoint(y), bool)
49+
assert_type(s.issubset(y), bool)
50+
assert_type(s.issuperset(y), bool)
51+
assert_type(s.symmetric_difference(y), frozenset[str])
52+
assert_type(s.union(y), frozenset[str])
53+
54+
assert_type(s - y, frozenset[Literal["foo", "bar"]])
55+
assert_type(s & y, frozenset[Literal["foo", "bar"]])
56+
assert_type(s | y, frozenset[str])
57+
assert_type(s ^ y, frozenset[str])

stdlib/builtins.pyi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,16 +1262,16 @@ class set(MutableSet[_T]):
12621262
def __init__(self, iterable: Iterable[_T], /) -> None: ...
12631263
def add(self, element: _T, /) -> None: ...
12641264
def copy(self) -> set[_T]: ...
1265-
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
1266-
def difference_update(self, *s: Iterable[Any]) -> None: ...
1267-
def discard(self, element: _T, /) -> None: ...
1268-
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
1269-
def intersection_update(self, *s: Iterable[Any]) -> None: ...
1270-
def isdisjoint(self, s: Iterable[Any], /) -> bool: ...
1271-
def issubset(self, s: Iterable[Any], /) -> bool: ...
1272-
def issuperset(self, s: Iterable[Any], /) -> bool: ...
1265+
def difference(self, *s: Iterable[object]) -> set[_T]: ...
1266+
def difference_update(self, *s: Iterable[object]) -> None: ...
1267+
def discard(self, element: object, /) -> None: ...
1268+
def intersection(self, *s: Iterable[object]) -> set[_T]: ...
1269+
def intersection_update(self, *s: Iterable[object]) -> None: ...
1270+
def isdisjoint(self, s: Iterable[object], /) -> bool: ...
1271+
def issubset(self, s: Iterable[object], /) -> bool: ...
1272+
def issuperset(self, s: Iterable[object], /) -> bool: ...
12731273
def remove(self, element: _T, /) -> None: ...
1274-
def symmetric_difference(self, s: Iterable[_T], /) -> set[_T]: ...
1274+
def symmetric_difference(self, s: Iterable[_S], /) -> set[_T | _S]: ...
12751275
def symmetric_difference_update(self, s: Iterable[_T], /) -> None: ...
12761276
def union(self, *s: Iterable[_S]) -> set[_T | _S]: ...
12771277
def update(self, *s: Iterable[_T]) -> None: ...
@@ -1303,15 +1303,15 @@ class frozenset(AbstractSet[_T_co]):
13031303
def copy(self) -> frozenset[_T_co]: ...
13041304
def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
13051305
def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
1306-
def isdisjoint(self, s: Iterable[_T_co], /) -> bool: ...
1306+
def isdisjoint(self, s: Iterable[object], /) -> bool: ...
13071307
def issubset(self, s: Iterable[object], /) -> bool: ...
13081308
def issuperset(self, s: Iterable[object], /) -> bool: ...
1309-
def symmetric_difference(self, s: Iterable[_T_co], /) -> frozenset[_T_co]: ...
1309+
def symmetric_difference(self, s: Iterable[_S], /) -> frozenset[_T_co | _S]: ...
13101310
def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ...
13111311
def __len__(self) -> int: ...
13121312
def __contains__(self, o: object, /) -> bool: ...
13131313
def __iter__(self) -> Iterator[_T_co]: ...
1314-
def __and__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ...
1314+
def __and__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ...
13151315
def __or__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ...
13161316
def __sub__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ...
13171317
def __xor__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ...

stdlib/encodings/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import sys
22
from codecs import CodecInfo
33

4+
from . import aliases as aliases
5+
46
class CodecRegistryError(LookupError, SystemError): ...
57

68
def normalize_encoding(encoding: str | bytes) -> str: ...

stdlib/urllib/request.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ else:
9292
context: None = None,
9393
) -> _UrlopenRet: ...
9494

95-
def install_opener(opener: OpenerDirector) -> None: ...
95+
def install_opener(opener: OpenerDirector | None) -> None: ...
9696
def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ...
9797

9898
if sys.version_info >= (3, 14):

stubs/datauri/METADATA.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version = "1.1.*"
2+
upstream_repository = "https://github.com/eclecticiq/python-data-uri"

stubs/datauri/datauri/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .datauri import DataURIError as DataURIError, discover as discover, parse as parse

stubs/datauri/datauri/datauri.pyi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from collections.abc import Generator
2+
from re import Pattern
3+
from typing import Final
4+
5+
RE_DATA_URI: Final[Pattern[str]] # undocumented
6+
7+
class DataURIError(ValueError): ...
8+
9+
class ParsedDataURI:
10+
media_type: str | None
11+
data: bytes
12+
uri: str
13+
14+
def __init__(self, media_type: str | None, data: bytes, uri: str) -> None: ...
15+
def __eq__(self, other: object) -> bool: ...
16+
def __hash__(self) -> int: ...
17+
18+
def parse(uri: str) -> ParsedDataURI: ...
19+
def discover(s: str) -> Generator[ParsedDataURI]: ...

stubs/networkx/networkx/classes/graph.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class Graph(Collection[_Node]):
100100
def copy(self, as_view: bool = False) -> Self: ...
101101
def to_directed(self, as_view: bool = False) -> DiGraph[_Node]: ...
102102
def to_undirected(self, as_view: bool = False) -> Graph[_Node]: ...
103-
def subgraph(self, nodes: _NBunch[_Node]) -> Graph[_Node]: ...
104-
def edge_subgraph(self, edges: Iterable[_Edge[_Node]]) -> Graph[_Node]: ...
103+
def subgraph(self, nodes: _NBunch[_Node]) -> Self: ...
104+
def edge_subgraph(self, edges: Iterable[_Edge[_Node]]) -> Self: ...
105105
@overload
106106
def size(self, weight: None = None) -> int: ...
107107
@overload

stubs/networkx/networkx/classes/multigraph.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MultiGraph(Graph[_Node]):
5252
def get_edge_data(
5353
self, u: _Node, v: _Node, key: None = None, default: _DefaultT | None = None
5454
) -> dict[Hashable, dict[str, Any] | _DefaultT]: ...
55-
def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ...
55+
def copy(self, as_view: bool = False) -> Self: ...
5656
@cached_property
5757
# Including subtypes' possible return types for LSP
5858
def degree(self) -> MultiDegreeView[_Node] | DiMultiDegreeView[_Node]: ...

stubs/python-dateutil/dateutil/parser/_parser.pyi

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from _typeshed import SupportsRead
33
from collections.abc import Callable, Mapping
44
from datetime import _TzInfo, datetime
55
from io import StringIO
6-
from typing import IO, Any
6+
from typing import IO, Any, Literal, overload
77
from typing_extensions import Self, TypeAlias
88

99
_FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any]
@@ -77,6 +77,7 @@ class _ymd(list[int]):
7777
class parser:
7878
info: parserinfo
7979
def __init__(self, info: parserinfo | None = None) -> None: ...
80+
@overload
8081
def parse(
8182
self,
8283
timestr: _FileOrStr,
@@ -87,11 +88,25 @@ class parser:
8788
dayfirst: bool | None = ...,
8889
yearfirst: bool | None = ...,
8990
fuzzy: bool = ...,
90-
fuzzy_with_tokens: bool = ...,
91+
fuzzy_with_tokens: Literal[False] = False,
9192
) -> datetime: ...
93+
@overload
94+
def parse(
95+
self,
96+
timestr: _FileOrStr,
97+
default: datetime | None = None,
98+
ignoretz: bool = False,
99+
tzinfos: _TzInfos | None = None,
100+
*,
101+
dayfirst: bool | None = ...,
102+
yearfirst: bool | None = ...,
103+
fuzzy: bool = ...,
104+
fuzzy_with_tokens: Literal[True],
105+
) -> tuple[datetime, tuple[str, ...]]: ...
92106

93107
DEFAULTPARSER: parser
94108

109+
@overload
95110
def parse(
96111
timestr: _FileOrStr,
97112
parserinfo: parserinfo | None = None,
@@ -100,10 +115,23 @@ def parse(
100115
yearfirst: bool | None = ...,
101116
ignoretz: bool = ...,
102117
fuzzy: bool = ...,
103-
fuzzy_with_tokens: bool = ...,
118+
fuzzy_with_tokens: Literal[False] = False,
104119
default: datetime | None = ...,
105120
tzinfos: _TzInfos | None = ...,
106121
) -> datetime: ...
122+
@overload
123+
def parse(
124+
timestr: _FileOrStr,
125+
parserinfo: parserinfo | None = None,
126+
*,
127+
dayfirst: bool | None = ...,
128+
yearfirst: bool | None = ...,
129+
ignoretz: bool = ...,
130+
fuzzy: bool = ...,
131+
fuzzy_with_tokens: Literal[True],
132+
default: datetime | None = ...,
133+
tzinfos: _TzInfos | None = ...,
134+
) -> tuple[datetime, tuple[str, ...]]: ...
107135

108136
class _tzparser:
109137
class _result(_resultbase):

0 commit comments

Comments
 (0)