Skip to content

Commit 36f4c4e

Browse files
committed
Merge branch 'argkinds' of https://github.com/BobTheBuidler/mypy into argkinds
2 parents d06c60e + e176a64 commit 36f4c4e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

mypy/nodes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,12 +2210,20 @@ def is_star(self) -> bool:
22102210
@mypyc_attr(native_class=False)
22112211
class ArgKinds(list[ArgKind]):
22122212
def __init__(self, values: Iterable[ArgKind] = None) -> None:
2213+
if values is None:
2214+
super().__init__()
2215+
else:
2216+
super().__init__(values)
22132217
self.__count_cache: dict[ArgKind, int] = {}
22142218
self.__index_cache: dict[ArgKind, int] = {}
2219+
self.__positional_only: bool | None = None
22152220

22162221
@property
22172222
def positional_only(self) -> bool:
2218-
return all(kind == ARG_POS for kind in self)
2223+
pos_only = self.__positional_only
2224+
if pos_only is None:
2225+
pos_only = self.__positional_only = all(kind == ARG_POS for kind in self)
2226+
return pos_only
22192227

22202228
@property
22212229
def has_star(self) -> bool:

mypy/types.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,11 @@ def __init__(
19171917
self.arg_types = list(arg_types)
19181918
self.arg_kinds = arg_kinds
19191919
self.arg_names = list(arg_names)
1920-
assert len(arg_types) == len(arg_kinds) == len(arg_names), (len(arg_types), len(arg_kinds), len(arg_names))
1920+
assert len(arg_types) == len(arg_kinds) == len(arg_names), (
1921+
len(arg_types),
1922+
len(arg_kinds),
1923+
len(arg_names),
1924+
)
19211925
assert not any(isinstance(t, Parameters) for t in arg_types)
19221926
self.min_args = arg_kinds.count(ARG_POS)
19231927
self.is_ellipsis_args = is_ellipsis_args
@@ -2158,7 +2162,11 @@ def __init__(
21582162
unpack_kwargs: bool = False,
21592163
) -> None:
21602164
super().__init__(line, column)
2161-
assert len(arg_types) == len(arg_kinds) == len(arg_names), (len(arg_types), len(arg_kinds), len(arg_names))
2165+
assert len(arg_types) == len(arg_kinds) == len(arg_names), (
2166+
len(arg_types),
2167+
len(arg_kinds),
2168+
len(arg_names),
2169+
)
21622170
self.arg_types = list(arg_types)
21632171
for t in self.arg_types:
21642172
if isinstance(t, ParamSpecType):

0 commit comments

Comments
 (0)