Process "isinstance(...)" in a way to avoid some extra dependencies.
(self, e: CallExpr)
| 747 | self.add_attribute_dependency(typ, "__call__") |
| 748 | |
| 749 | def process_isinstance_call(self, e: CallExpr) -> None: |
| 750 | """Process "isinstance(...)" in a way to avoid some extra dependencies.""" |
| 751 | if len(e.args) == 2: |
| 752 | arg = e.args[1] |
| 753 | if ( |
| 754 | isinstance(arg, RefExpr) |
| 755 | and arg.kind == GDEF |
| 756 | and isinstance(arg.node, TypeInfo) |
| 757 | and arg.fullname |
| 758 | ): |
| 759 | # Special case to avoid redundant dependencies from "__init__". |
| 760 | self.add_dependency(make_trigger(arg.fullname)) |
| 761 | return |
| 762 | # In uncommon cases generate normal dependencies. These will include |
| 763 | # spurious dependencies, but the performance impact is small. |
| 764 | super().visit_call_expr(e) |
| 765 | |
| 766 | def visit_cast_expr(self, e: CastExpr) -> None: |
| 767 | super().visit_cast_expr(e) |
no test coverage detected