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

Method collect_vars

mypy/applytype.py:224–236  ·  view source on GitHub ↗
(self, t: CallableType | Parameters)

Source from the content-addressed store, hash-verified

222 self.seen_aliases = seen_aliases
223
224 def collect_vars(self, t: CallableType | Parameters) -> list[TypeVarLikeType]:
225 found_vars = []
226 for arg in t.arg_types:
227 for tv in get_all_type_vars(arg):
228 if isinstance(tv, ParamSpecType):
229 normalized: TypeVarLikeType = tv.copy_modified(
230 flavor=ParamSpecFlavor.BARE, prefix=Parameters([], [], [])
231 )
232 else:
233 normalized = tv
234 if normalized in self.poly_tvars and normalized not in self.bound_tvars:
235 found_vars.append(normalized)
236 return remove_dups(found_vars)
237
238 def visit_callable_type(self, t: CallableType) -> Type:
239 found_vars = self.collect_vars(t)

Callers 2

visit_callable_typeMethod · 0.95
visit_instanceMethod · 0.95

Calls 6

get_all_type_varsFunction · 0.90
ParametersClass · 0.90
remove_dupsFunction · 0.90
isinstanceFunction · 0.85
appendMethod · 0.80
copy_modifiedMethod · 0.45

Tested by

no test coverage detected