|
6 | 6 | import os |
7 | 7 | from abc import abstractmethod |
8 | 8 | from collections import defaultdict |
9 | | -from collections.abc import Iterator, Sequence |
| 9 | +from collections.abc import Iterable, Iterator, Sequence |
10 | 10 | from enum import Enum, unique |
11 | | -from typing import TYPE_CHECKING, Any, Callable, Final, Iterable, Optional, TypeVar, Union, cast |
| 11 | +from typing import TYPE_CHECKING, Any, Callable, Final, Optional, TypeVar, Union, cast |
12 | 12 | from typing_extensions import TypeAlias as _TypeAlias, TypeGuard |
13 | 13 |
|
14 | 14 | from mypy_extensions import mypyc_attr, trait |
@@ -2210,29 +2210,38 @@ def is_star(self) -> bool: |
2210 | 2210 | @mypyc_attr(native_class=False) |
2211 | 2211 | class ArgKinds(list[ArgKind]): |
2212 | 2212 | def __init__(self, values: Iterable[ArgKind] = None) -> None: |
2213 | | - self._count_cache: dict[ArgKind, int] = {} |
2214 | | - self._index_cache: dict[ArgKind, int] = {} |
| 2213 | + self.__count_cache: dict[ArgKind, int] = {} |
| 2214 | + self.__index_cache: dict[ArgKind, int] = {} |
| 2215 | + |
2215 | 2216 | @property |
2216 | 2217 | def positional_only(self) -> bool: |
2217 | 2218 | return all(kind == ARG_POS for kind in self) |
| 2219 | + |
2218 | 2220 | @property |
2219 | 2221 | def has_star(self) -> bool: |
2220 | 2222 | return ARG_STAR in self |
| 2223 | + |
2221 | 2224 | @property |
2222 | 2225 | def has_star2(self) -> bool: |
2223 | 2226 | return ARG_STAR2 in self |
| 2227 | + |
2224 | 2228 | @property |
2225 | 2229 | def has_any_star(self) -> bool: |
2226 | 2230 | return any(kind.is_star() for kind in self) |
| 2231 | + |
| 2232 | + def copy(self) -> ArgKinds: |
| 2233 | + return ArgKinds(kind for kind in self) |
| 2234 | + |
2227 | 2235 | def count(self, kind: ArgKind) -> int: |
2228 | | - count = self._count_cache.get(kind) |
| 2236 | + count = self.__count_cache.get(kind) |
2229 | 2237 | if count is None: |
2230 | | - count = self._count_cache[kind] = super().count(kind) |
| 2238 | + count = self.__count_cache[kind] = super().count(kind) |
2231 | 2239 | return count |
| 2240 | + |
2232 | 2241 | def index(self, kind: ArgKind) -> int: |
2233 | | - index = self._index_cache.get(kind) |
| 2242 | + index = self.__index_cache.get(kind) |
2234 | 2243 | if index is None: |
2235 | | - index = self._index_cache[kind] = super().index(kind) |
| 2244 | + index = self.__index_cache[kind] = super().index(kind) |
2236 | 2245 | return index |
2237 | 2246 |
|
2238 | 2247 |
|
@@ -4827,9 +4836,7 @@ def get_member_expr_fullname(expr: MemberExpr) -> str | None: |
4827 | 4836 | } |
4828 | 4837 |
|
4829 | 4838 |
|
4830 | | -def check_arg_kinds( |
4831 | | - arg_kinds: ArgKinds, nodes: list[T], fail: Callable[[str, T], None] |
4832 | | -) -> None: |
| 4839 | +def check_arg_kinds(arg_kinds: ArgKinds, nodes: list[T], fail: Callable[[str, T], None]) -> None: |
4833 | 4840 | is_var_arg = False |
4834 | 4841 | is_kw_arg = False |
4835 | 4842 | seen_named = False |
|
0 commit comments