(self, o: WithStmt, /)
| 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 |
nothing calls this directly
no test coverage detected