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

Method callable

mypy/test/testtypes.py:667–689  ·  view source on GitHub ↗

callable(args, a1, ..., an, r) constructs a callable with argument types a1, ... an and return type r and type arguments vars.

(self, vars: list[str], *a: Type)

Source from the content-addressed store, hash-verified

665 return TupleType(list(a), self.fx.std_tuple)
666
667 def callable(self, vars: list[str], *a: Type) -> CallableType:
668 """callable(args, a1, ..., an, r) constructs a callable with
669 argument types a1, ... an and return type r and type arguments
670 vars.
671 """
672 tv: list[TypeVarType] = []
673 n = -1
674 for v in vars:
675 tv.append(
676 TypeVarType(
677 v, v, TypeVarId(n), [], self.fx.o, AnyType(TypeOfAny.from_omitted_generics)
678 )
679 )
680 n -= 1
681 return CallableType(
682 list(a[:-1]),
683 [ARG_POS] * (len(a) - 1),
684 [None] * (len(a) - 1),
685 a[-1],
686 self.fx.function,
687 name=None,
688 variables=tv,
689 )
690
691
692class JoinSuite(Suite):

Callers 1

test_trivial_expandMethod · 0.95

Calls 7

TypeVarTypeClass · 0.90
TypeVarIdClass · 0.90
AnyTypeClass · 0.90
CallableTypeClass · 0.90
listClass · 0.85
lenFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected