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

Function is_dangerous_target

mypy/plugins/proper_plugin.py:132–138  ·  view source on GitHub ↗

Is this a dangerous target (right argument) for an isinstance() check?

(typ: ProperType)

Source from the content-addressed store, hash-verified

130
131
132def is_dangerous_target(typ: ProperType) -> bool:
133 """Is this a dangerous target (right argument) for an isinstance() check?"""
134 if isinstance(typ, TupleType):
135 return any(is_dangerous_target(get_proper_type(t)) for t in typ.items)
136 if isinstance(typ, FunctionLike) and typ.is_type_obj():
137 return typ.type_object().has_base("mypy.types.Type")
138 return False
139
140
141def proper_type_hook(ctx: FunctionContext) -> Type:

Callers 1

isinstance_proper_hookFunction · 0.85

Calls 6

get_proper_typeFunction · 0.90
isinstanceFunction · 0.85
anyFunction · 0.85
has_baseMethod · 0.80
is_type_objMethod · 0.45
type_objectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…