MCPcopy Create free account
hub / github.com/python/mypy / check_iteration

Method check_iteration

mypyc/annotate.py:283–297  ·  view source on GitHub ↗
(self, expressions: list[Expression], kind: str)

Source from the content-addressed store, hash-verified

281 super().visit_generator_expr(o)
282
283 def check_iteration(self, expressions: list[Expression], kind: str) -> None:
284 for expr in expressions:
285 typ = self.get_type(expr)
286 if isinstance(typ, AnyType):
287 self.annotate(expr, f'{kind} uses generic operations (iterable has type "Any").')
288 elif isinstance(typ, Instance) and typ.type.fullname in (
289 "typing.Iterable",
290 "typing.Iterator",
291 "typing.Sequence",
292 "typing.MutableSequence",
293 ):
294 self.annotate(
295 expr,
296 f'{kind} uses generic operations (iterable has the abstract type "{typ.type.fullname}").',
297 )
298
299 def visit_class_def(self, o: ClassDef, /) -> None:
300 super().visit_class_def(o)

Callers 3

visit_for_stmtMethod · 0.95
visit_generator_exprMethod · 0.95

Calls 3

get_typeMethod · 0.95
annotateMethod · 0.95
isinstanceFunction · 0.85

Tested by

no test coverage detected