@@ -1026,8 +1026,10 @@ def analyze_callable_args_for_paramspec(
1026
1026
def analyze_callable_args_for_concatenate (
1027
1027
self , callable_args : Type , ret_type : Type , fallback : Instance
1028
1028
) -> CallableType | None :
1029
- """Construct a 'Callable[C, RET]', where C is Concatenate[..., P], returning None if we
1030
- cannot.
1029
+ """Construct a 'Callable[C, RET]', where C is Concatenate[..., P]
1030
+
1031
+ Return `None` if we cannot.
1032
+ Return `AnyType` if we only can do it partially.
1031
1033
"""
1032
1034
if not isinstance (callable_args , UnboundType ):
1033
1035
return None
@@ -1039,7 +1041,17 @@ def analyze_callable_args_for_concatenate(
1039
1041
if sym .node .fullname not in ("typing_extensions.Concatenate" , "typing.Concatenate" ):
1040
1042
return None
1041
1043
1042
- tvar_def = self .anal_type (callable_args , allow_param_spec = True )
1044
+ tvar_def = get_proper_type (self .anal_type (callable_args , allow_param_spec = True ))
1045
+ if isinstance (tvar_def , AnyType ) and tvar_def .type_of_any == TypeOfAny .from_error :
1046
+ # Some error happened, we won't be able to construct a proper type anyway.
1047
+ # So, instead return a callable that accepts anything.
1048
+ return CallableType (
1049
+ arg_names = [None ] * 2 ,
1050
+ arg_types = [AnyType (TypeOfAny .from_error )] * 2 ,
1051
+ arg_kinds = [ARG_STAR , ARG_STAR2 ],
1052
+ ret_type = AnyType (TypeOfAny .from_error ),
1053
+ fallback = fallback ,
1054
+ )
1043
1055
if not isinstance (tvar_def , ParamSpecType ):
1044
1056
return None
1045
1057
0 commit comments