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

Method check_paramspec_default

mypy/semanal.py:4838–4855  ·  view source on GitHub ↗
(self, default: Type, context: Context)

Source from the content-addressed store, hash-verified

4836 return default
4837
4838 def check_paramspec_default(self, default: Type, context: Context) -> Type:
4839 typ = get_proper_type(default)
4840 if isinstance(typ, Parameters):
4841 for i, arg_type in enumerate(typ.arg_types):
4842 arg_ptype = get_proper_type(arg_type)
4843 if isinstance(arg_ptype, AnyType) and arg_ptype.is_from_error:
4844 self.fail(f"Argument {i} of ParamSpec default must be a type", context)
4845 elif (
4846 isinstance(typ, AnyType)
4847 and typ.is_from_error
4848 or not isinstance(typ, (AnyType, UnboundType))
4849 ):
4850 self.fail(
4851 "The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec",
4852 context,
4853 )
4854 default = AnyType(TypeOfAny.from_error)
4855 return default
4856
4857 def check_typevartuple_default(self, default: Type, context: Context) -> Type:
4858 typ = get_proper_type(default)

Callers 2

analyze_type_paramMethod · 0.95

Calls 5

failMethod · 0.95
get_proper_typeFunction · 0.90
AnyTypeClass · 0.90
isinstanceFunction · 0.85
enumerateFunction · 0.85

Tested by

no test coverage detected