MCPcopy Index your code
hub / github.com/python/mypy / visit_with_stmt

Method visit_with_stmt

mypyc/annotate.py:315–333  ·  view source on GitHub ↗
(self, o: WithStmt, /)

Source from the content-addressed store, hash-verified

313 self.ignored_lines.add(s.func.line)
314
315 def visit_with_stmt(self, o: WithStmt, /) -> None:
316 for expr in o.expr:
317 if isinstance(expr, CallExpr) and isinstance(expr.callee, RefExpr):
318 node = expr.callee.node
319 if isinstance(node, Decorator):
320 if any(
321 isinstance(d, RefExpr)
322 and d.node
323 and d.node.fullname == "contextlib.contextmanager"
324 for d in node.decorators
325 ):
326 self.annotate(
327 expr,
328 f'"{node.name}" uses @contextmanager, which is slow '
329 + "in compiled code. Use a native class with "
330 + '"__enter__" and "__exit__" methods instead.',
331 priority=3,
332 )
333 super().visit_with_stmt(o)
334
335 def visit_assignment_stmt(self, o: AssignmentStmt, /) -> None:
336 special_form = False

Callers

nothing calls this directly

Calls 3

annotateMethod · 0.95
isinstanceFunction · 0.85
anyFunction · 0.85

Tested by

no test coverage detected