(
self, defn: FuncItem, typ: CallableType
)
| 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, |
no test coverage detected