Skip to content

Commit fac1e07

Browse files
address review
1 parent 08db3da commit fac1e07

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

mypy/argmap.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def is_iterable(self, typ: Type) -> bool:
283283
return is_subtype(typ, self.context.iterable_type)
284284

285285
def is_iterable_instance_type(self, typ: Type) -> TypeGuard[IterableType]:
286-
"""Check if the type is an Iterable[T] or a subtype of it."""
286+
"""Check if the type is an Iterable[T]."""
287287
p_t = get_proper_type(typ)
288288
return isinstance(p_t, Instance) and p_t.type == self.context.iterable_type.type
289289

@@ -363,7 +363,10 @@ def as_iterable_type(self, typ: Type) -> IterableType | AnyType:
363363
if self.is_iterable_instance_type(r):
364364
args.append(r.args[0])
365365
else:
366-
# this *should* never happen
366+
# this *should* never happen, since UnpackType should
367+
# only contain TypeVarTuple or a variable length tuple.
368+
# However, we could get an `AnyType(TypeOfAny.from_error)`
369+
# if for some reason the solver was triggered and failed.
367370
args.append(r)
368371
else:
369372
args.append(p_e)
@@ -416,7 +419,7 @@ def parse_star_args_type(
416419
else:
417420
converted_types = [self.as_iterable_type(p_i) for p_i in proper_items]
418421
if all(self.is_iterable_instance_type(it) for it in converted_types):
419-
# all items are iterable, return Iterable[T₁ | T₂ | ... | Tₙ]
422+
# all items are iterable, return Iterable[T1 | T2 | ... | Tn]
420423
iterables = cast(list[IterableType], converted_types)
421424
arg = make_simplified_union([it.args[0] for it in iterables])
422425
return self._make_iterable_instance_type(arg)

test-data/unit/lib-stub/builtins.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ class function:
2323
__name__: str
2424
class ellipsis: pass
2525

26-
from typing import Generic, Iterator, Sequence, TypeVar, Iterable
26+
from typing import Generic, Iterator, Sequence, TypeVar
2727
_T = TypeVar('_T')
2828
class list(Generic[_T], Sequence[_T]):
2929
def __contains__(self, item: object) -> bool: pass
3030
def __getitem__(self, key: int) -> _T: pass
3131
def __iter__(self) -> Iterator[_T]: pass
3232

33-
# class tuple(Generic[_T], Sequence[_T]):
34-
# def __contains__(self, item: object) -> bool: pass
35-
# def __getitem__(self, key: int) -> _T: pass
36-
# def __iter__(self) -> Iterator[_T]: pass
37-
3833
class dict: pass
34+
3935
# Definition of None is implicit

0 commit comments

Comments
 (0)