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

Method process_isinstance_call

mypy/server/deps.py:749–764  ·  view source on GitHub ↗

Process "isinstance(...)" in a way to avoid some extra dependencies.

(self, e: CallExpr)

Source from the content-addressed store, hash-verified

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)

Callers 1

visit_call_exprMethod · 0.95

Calls 5

add_dependencyMethod · 0.95
make_triggerFunction · 0.90
lenFunction · 0.85
isinstanceFunction · 0.85
visit_call_exprMethod · 0.45

Tested by

no test coverage detected