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

Method expand_typevars

mypy/checker.py:2260–2282  ·  view source on GitHub ↗
(
        self, defn: FuncItem, typ: CallableType
    )

Source from the content-addressed store, hash-verified

2258 )
2259
2260 def expand_typevars(
2261 self, defn: FuncItem, typ: CallableType
2262 ) -> list[tuple[FuncItem, CallableType]]:
2263 # TODO use generator
2264 subst: list[list[tuple[TypeVarId, Type]]] = []
2265 tvars = list(typ.variables) or []
2266 if defn.info:
2267 # Class type variables
2268 tvars += defn.info.defn.type_vars or []
2269 for tvar in tvars:
2270 if isinstance(tvar, TypeVarType) and tvar.values:
2271 subst.append([(tvar.id, value) for value in tvar.values])
2272 # Make a copy of the function to check for each combination of
2273 # value restricted type variables. (Except when running mypyc,
2274 # where we need one canonical version of the function.)
2275 if subst and not (self.options.mypyc or self.options.inspections):
2276 result: list[tuple[FuncItem, CallableType]] = []
2277 for substitutions in itertools.product(*subst):
2278 mapping = dict(substitutions)
2279 result.append((expand_func(defn, mapping), expand_type(typ, mapping)))
2280 return result
2281 else:
2282 return [(defn, typ)]
2283
2284 def check_explicit_override_decorator(
2285 self,

Callers 1

check_func_defMethod · 0.95

Calls 6

expand_typeFunction · 0.90
listClass · 0.85
isinstanceFunction · 0.85
dictClass · 0.85
expand_funcFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected