@@ -1605,6 +1605,9 @@ def with_name(self, name: str) -> FunctionLike:
16051605 def get_name (self ) -> str | None :
16061606 pass
16071607
1608+ def bound (self ) -> bool :
1609+ return bool (self .items ) and self .items [0 ].is_bound
1610+
16081611
16091612class FormalArgument (NamedTuple ):
16101613 name : str | None
@@ -1834,8 +1837,7 @@ class CallableType(FunctionLike):
18341837 # 'dict' and 'partial' for a `functools.partial` evaluation)
18351838 "from_type_type" , # Was this callable generated by analyzing Type[...]
18361839 # instantiation?
1837- "bound_args" , # Bound type args, mostly unused but may be useful for
1838- # tools that consume mypy ASTs
1840+ "is_bound" , # Is this a bound method?
18391841 "def_extras" , # Information about original definition we want to serialize.
18401842 # This is used for more detailed error messages.
18411843 "type_guard" , # T, if -> TypeGuard[T] (ret_type is bool in this case).
@@ -1863,7 +1865,7 @@ def __init__(
18631865 implicit : bool = False ,
18641866 special_sig : str | None = None ,
18651867 from_type_type : bool = False ,
1866- bound_args : Sequence [ Type | None ] = () ,
1868+ is_bound : bool = False ,
18671869 def_extras : dict [str , Any ] | None = None ,
18681870 type_guard : Type | None = None ,
18691871 type_is : Type | None = None ,
@@ -1896,9 +1898,7 @@ def __init__(
18961898 self .from_type_type = from_type_type
18971899 self .from_concatenate = from_concatenate
18981900 self .imprecise_arg_kinds = imprecise_arg_kinds
1899- if not bound_args :
1900- bound_args = ()
1901- self .bound_args = bound_args
1901+ self .is_bound = is_bound
19021902 if def_extras :
19031903 self .def_extras = def_extras
19041904 elif isinstance (definition , FuncDef ):
@@ -1935,7 +1935,7 @@ def copy_modified(
19351935 implicit : Bogus [bool ] = _dummy ,
19361936 special_sig : Bogus [str | None ] = _dummy ,
19371937 from_type_type : Bogus [bool ] = _dummy ,
1938- bound_args : Bogus [list [ Type | None ] ] = _dummy ,
1938+ is_bound : Bogus [bool ] = _dummy ,
19391939 def_extras : Bogus [dict [str , Any ]] = _dummy ,
19401940 type_guard : Bogus [Type | None ] = _dummy ,
19411941 type_is : Bogus [Type | None ] = _dummy ,
@@ -1960,7 +1960,7 @@ def copy_modified(
19601960 implicit = implicit if implicit is not _dummy else self .implicit ,
19611961 special_sig = special_sig if special_sig is not _dummy else self .special_sig ,
19621962 from_type_type = from_type_type if from_type_type is not _dummy else self .from_type_type ,
1963- bound_args = bound_args if bound_args is not _dummy else self .bound_args ,
1963+ is_bound = is_bound if is_bound is not _dummy else self .is_bound ,
19641964 def_extras = def_extras if def_extras is not _dummy else dict (self .def_extras ),
19651965 type_guard = type_guard if type_guard is not _dummy else self .type_guard ,
19661966 type_is = type_is if type_is is not _dummy else self .type_is ,
@@ -2285,7 +2285,7 @@ def serialize(self) -> JsonDict:
22852285 "variables" : [v .serialize () for v in self .variables ],
22862286 "is_ellipsis_args" : self .is_ellipsis_args ,
22872287 "implicit" : self .implicit ,
2288- "bound_args " : [( None if t is None else t . serialize ()) for t in self .bound_args ] ,
2288+ "is_bound " : self .is_bound ,
22892289 "def_extras" : dict (self .def_extras ),
22902290 "type_guard" : self .type_guard .serialize () if self .type_guard is not None else None ,
22912291 "type_is" : (self .type_is .serialize () if self .type_is is not None else None ),
@@ -2308,7 +2308,7 @@ def deserialize(cls, data: JsonDict) -> CallableType:
23082308 variables = [cast (TypeVarLikeType , deserialize_type (v )) for v in data ["variables" ]],
23092309 is_ellipsis_args = data ["is_ellipsis_args" ],
23102310 implicit = data ["implicit" ],
2311- bound_args = [( None if t is None else deserialize_type ( t )) for t in data ["bound_args" ] ],
2311+ is_bound = data ["is_bound" ],
23122312 def_extras = data ["def_extras" ],
23132313 type_guard = (
23142314 deserialize_type (data ["type_guard" ]) if data ["type_guard" ] is not None else None
0 commit comments