Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48106fe

Browse files
chore(deps): update pytype and pyright (#11595)
1 parent a1bfd65 commit 48106fe

12 files changed

Lines changed: 76 additions & 52 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,5 @@ extra-standard-library = [
149149
known-first-party = ["parse_metadata", "utils"]
150150

151151
[tool.typeshed]
152-
pyright_version = "1.1.350"
152+
pyright_version = "1.1.354"
153153
oldest_supported_python = "3.8"

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ flake8-noqa==1.4.0 # must match .pre-commit-config.yaml
77
flake8-pyi==24.3.0 # must match .pre-commit-config.yaml
88
mypy==1.9.0
99
pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml
10-
pytype==2024.2.27; platform_system != "Windows" and python_version < "3.12"
10+
pytype==2024.3.11; platform_system != "Windows" and python_version < "3.12"
1111
ruff==0.3.0 # must match .pre-commit-config.yaml
1212

1313
# Libraries used by our various scripts.

scripts/stubsabot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ async def determine_action(stub_path: Path, session: aiohttp.ClientSession) -> U
473473

474474
relevant_version = obsolete_since.version if obsolete_since else latest_version
475475

476-
project_urls = pypi_info.info["project_urls"] or {}
476+
project_urls: dict[str, str] = pypi_info.info["project_urls"] or {}
477477
maybe_links: dict[str, str | None] = {
478478
"Release": f"{pypi_info.pypi_root}/{relevant_version}",
479479
"Homepage": project_urls.get("Homepage"),

stdlib/collections/__init__.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ class UserList(MutableSequence[_T]):
137137
def copy(self) -> Self: ...
138138
def __copy__(self) -> Self: ...
139139
def count(self, item: _T) -> int: ...
140-
# All arguments are passed to `list.index` at runtime, so the signature should be kept in line with `list.index`.
141-
def index(self, item: _T, __start: SupportsIndex = 0, __stop: SupportsIndex = sys.maxsize) -> int: ...
140+
# The runtime signature is "item, *args", and the arguments are then passed
141+
# to `list.index`. In order to give more precise types, we pretend that the
142+
# `item` argument is positional-only.
143+
def index(self, item: _T, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ...
142144
# All arguments are passed to `list.sort` at runtime, so the signature should be kept in line with `list.sort`.
143145
@overload
144146
def sort(self: UserList[SupportsRichComparisonT], *, key: None = None, reverse: bool = False) -> None: ...
@@ -459,7 +461,11 @@ class ChainMap(MutableMapping[_KT, _VT]):
459461
# All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, so the signature should be kept in line with `dict.fromkeys`.
460462
@classmethod
461463
@overload
462-
def fromkeys(cls, iterable: Iterable[_T], __value: None = None) -> ChainMap[_T, Any | None]: ...
464+
def fromkeys(cls, iterable: Iterable[_T]) -> ChainMap[_T, Any | None]: ...
465+
@classmethod
466+
@overload
467+
# Special-case None: the user probably wants to add non-None values later.
468+
def fromkeys(cls, iterable: Iterable[_T], value: None, /) -> ChainMap[_T, Any | None]: ...
463469
@classmethod
464470
@overload
465471
def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> ChainMap[_T, _S]: ...

stdlib/dataclasses.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,18 @@ if sys.version_info >= (3, 9):
227227
else:
228228
class _InitVarMeta(type):
229229
# Not used, instead `InitVar.__class_getitem__` is called.
230-
def __getitem__(self, params: Any) -> InitVar[Any]: ...
230+
# pyright ignore is needed because pyright (not unreasonably) thinks this
231+
# is an invalid use of InitVar.
232+
def __getitem__(self, params: Any) -> InitVar[Any]: ... # pyright: ignore
231233

232234
class InitVar(Generic[_T], metaclass=_InitVarMeta):
233235
type: Type[_T]
234236
def __init__(self, type: Type[_T]) -> None: ...
235237
if sys.version_info >= (3, 9):
236238
@overload
237-
def __class_getitem__(cls, type: Type[_T]) -> InitVar[_T]: ...
239+
def __class_getitem__(cls, type: Type[_T]) -> InitVar[_T]: ... # pyright: ignore
238240
@overload
239-
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ...
241+
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ... # pyright: ignore
240242

241243
if sys.version_info >= (3, 12):
242244
def make_dataclass(

stubs/gevent/@tests/stubtest_allowlist.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,8 @@ gevent.events.IPeriodicMonitorThreadStartedEvent
217217
# internal use module for some complex protocols used across different modules
218218
# so there wasn't really a great place for them
219219
gevent._types
220+
221+
# The first parameter is technically positional-or-keyword but there's no
222+
# useful way to use it as a keyword argument; we mark it positional-only.
223+
gevent.pool.GroupMappingMixin.imap
224+
gevent.pool.GroupMappingMixin.imap_unordered

stubs/gevent/gevent/pool.pyi

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -47,108 +47,116 @@ class GroupMappingMixin:
4747
self, func: Callable[[_T], _S], iterable: Iterable[_T], callback: Callable[[list[_S]], object] | None = None
4848
) -> Greenlet[..., list[_S]]: ...
4949
@overload
50-
def imap(self, func: Callable[[_T1], _S], __iter1: Iterable[_T1], *, maxsize: int | None = None) -> IMap[[_T1], _S]: ...
50+
def imap(self, func: Callable[[_T1], _S], iter1: Iterable[_T1], /, *, maxsize: int | None = None) -> IMap[[_T1], _S]: ...
5151
@overload
5252
def imap(
53-
self, func: Callable[[_T1, _T2], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2], *, maxsize: int | None = None
53+
self, func: Callable[[_T1, _T2], _S], iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, maxsize: int | None = None
5454
) -> IMap[[_T1, _T2], _S]: ...
5555
@overload
5656
def imap(
5757
self,
5858
func: Callable[[_T1, _T2, _T3], _S],
59-
__iter1: Iterable[_T1],
60-
__iter2: Iterable[_T2],
61-
__iter3: Iterable[_T3],
59+
iter1: Iterable[_T1],
60+
iter2: Iterable[_T2],
61+
iter3: Iterable[_T3],
62+
/,
6263
*,
6364
maxsize: int | None = None,
6465
) -> IMap[[_T1, _T2, _T3], _S]: ...
6566
@overload
6667
def imap(
6768
self,
6869
func: Callable[[_T1, _T2, _T3, _T4], _S],
69-
__iter1: Iterable[_T1],
70-
__iter2: Iterable[_T2],
71-
__iter3: Iterable[_T3],
72-
__iter4: Iterable[_T4],
70+
iter1: Iterable[_T1],
71+
iter2: Iterable[_T2],
72+
iter3: Iterable[_T3],
73+
iter4: Iterable[_T4],
74+
/,
7375
*,
7476
maxsize: int | None = None,
7577
) -> IMap[[_T1, _T2, _T3, _T4], _S]: ...
7678
@overload
7779
def imap(
7880
self,
7981
func: Callable[[_T1, _T2, _T3, _T4, _T5], _S],
80-
__iter1: Iterable[_T1],
81-
__iter2: Iterable[_T2],
82-
__iter3: Iterable[_T3],
83-
__iter4: Iterable[_T4],
84-
__iter5: Iterable[_T5],
82+
iter1: Iterable[_T1],
83+
iter2: Iterable[_T2],
84+
iter3: Iterable[_T3],
85+
iter4: Iterable[_T4],
86+
iter5: Iterable[_T5],
87+
/,
8588
*,
8689
maxsize: int | None = None,
8790
) -> IMap[[_T1, _T2, _T3, _T4, _T5], _S]: ...
8891
@overload
8992
def imap(
9093
self,
9194
func: Callable[_P, _S],
92-
__iter1: Iterable[Any],
93-
__iter2: Iterable[Any],
94-
__iter3: Iterable[Any],
95-
__iter4: Iterable[Any],
96-
__iter5: Iterable[Any],
97-
__iter6: Iterable[Any],
95+
iter1: Iterable[Any],
96+
iter2: Iterable[Any],
97+
iter3: Iterable[Any],
98+
iter4: Iterable[Any],
99+
iter5: Iterable[Any],
100+
iter6: Iterable[Any],
101+
/,
98102
*iterables: Iterable[Any],
99103
maxsize: int | None = None,
100104
) -> IMap[_P, _S]: ...
101105
@overload
102106
def imap_unordered(
103-
self, func: Callable[[_T1], _S], __iter1: Iterable[_T1], *, maxsize: int | None = None
107+
self, func: Callable[[_T1], _S], iter1: Iterable[_T1], /, *, maxsize: int | None = None
104108
) -> IMapUnordered[[_T1], _S]: ...
105109
@overload
106110
def imap_unordered(
107-
self, func: Callable[[_T1, _T2], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2], *, maxsize: int | None = None
111+
self, func: Callable[[_T1, _T2], _S], iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, maxsize: int | None = None
108112
) -> IMapUnordered[[_T1, _T2], _S]: ...
109113
@overload
110114
def imap_unordered(
111115
self,
112116
func: Callable[[_T1, _T2, _T3], _S],
113-
__iter1: Iterable[_T1],
114-
__iter2: Iterable[_T2],
115-
__iter3: Iterable[_T3],
117+
iter1: Iterable[_T1],
118+
iter2: Iterable[_T2],
119+
iter3: Iterable[_T3],
120+
/,
116121
*,
117122
maxsize: int | None = None,
118123
) -> IMapUnordered[[_T1, _T2, _T3], _S]: ...
119124
@overload
120125
def imap_unordered(
121126
self,
122127
func: Callable[[_T1, _T2, _T3, _T4], _S],
123-
__iter1: Iterable[_T1],
124-
__iter2: Iterable[_T2],
125-
__iter3: Iterable[_T3],
126-
__iter4: Iterable[_T4],
128+
iter1: Iterable[_T1],
129+
iter2: Iterable[_T2],
130+
iter3: Iterable[_T3],
131+
iter4: Iterable[_T4],
132+
/,
127133
*,
128134
maxsize: int | None = None,
129135
) -> IMapUnordered[[_T1, _T2, _T3, _T4], _S]: ...
130136
@overload
131137
def imap_unordered(
132138
self,
133139
func: Callable[[_T1, _T2, _T3, _T4, _T5], _S],
134-
__iter1: Iterable[_T1],
135-
__iter2: Iterable[_T2],
136-
__iter3: Iterable[_T3],
137-
__iter4: Iterable[_T4],
138-
__iter5: Iterable[_T5],
140+
iter1: Iterable[_T1],
141+
iter2: Iterable[_T2],
142+
iter3: Iterable[_T3],
143+
iter4: Iterable[_T4],
144+
iter5: Iterable[_T5],
145+
/,
139146
*,
140147
maxsize: int | None = None,
141148
) -> IMapUnordered[[_T1, _T2, _T3, _T4, _T5], _S]: ...
142149
@overload
143150
def imap_unordered(
144151
self,
145152
func: Callable[_P, _S],
146-
__iter1: Iterable[Any],
147-
__iter2: Iterable[Any],
148-
__iter3: Iterable[Any],
149-
__iter4: Iterable[Any],
150-
__iter5: Iterable[Any],
151-
__iter6: Iterable[Any],
153+
iter1: Iterable[Any],
154+
iter2: Iterable[Any],
155+
iter3: Iterable[Any],
156+
iter4: Iterable[Any],
157+
iter5: Iterable[Any],
158+
iter6: Iterable[Any],
159+
/,
152160
*iterables: Iterable[Any],
153161
maxsize: int | None = None,
154162
) -> IMapUnordered[_P, _S]: ...

stubs/gevent/gevent/resolver/cares.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if sys.platform != "win32":
1818

1919
class ares_host_result(tuple[str, list[str], list[str]]):
2020
family: int
21-
def __new__(cls, family: int, __hostname: str, __aliases: list[str], __addr_list: list[str]) -> Self: ...
21+
def __new__(cls, family: int, hostname: str, aliases: list[str], addr_list: list[str], /) -> Self: ...
2222

2323
class channel:
2424
@property

tests/stubtest_allowlists/py310.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ asyncio.base_events.BaseEventLoop.subprocess_exec # BaseEventLoop adds several p
44
builtins.float.__setformat__ # Internal method for CPython test suite
55
builtins.property.__set_name__ # Doesn't actually exist
66
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
7+
collections\.UserList\.index # ignoring pos-or-keyword parameter
78
configparser.ParsingError.filename
89
contextlib.AbstractAsyncContextManager.__class_getitem__
910
contextlib.AbstractContextManager.__class_getitem__

tests/stubtest_allowlists/py311.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _csv.Writer
88
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
99
configparser.LegacyInterpolation.__init__
1010
configparser.ParsingError.filename
11+
collections\.UserList\.index # ignoring pos-or-keyword parameter
1112
enum.Enum.__init__
1213
enum.Enum._generate_next_value_
1314
# Not strictly speaking a staticmethod on 3.11, but it acts like one:

0 commit comments

Comments
 (0)