@@ -1597,6 +1597,9 @@ def with_name(self, name: str) -> FunctionLike:
15971597 def get_name (self ) -> str | None :
15981598 pass
15991599
1600+ def bound (self ) -> bool :
1601+ return bool (self .items ) and self .items [0 ].is_bound
1602+
16001603
16011604class FormalArgument (NamedTuple ):
16021605 name : str | None
@@ -1826,8 +1829,7 @@ class CallableType(FunctionLike):
18261829 # 'dict' and 'partial' for a `functools.partial` evaluation)
18271830 "from_type_type" , # Was this callable generated by analyzing Type[...]
18281831 # instantiation?
1829- "bound_args" , # Bound type args, mostly unused but may be useful for
1830- # tools that consume mypy ASTs
1832+ "is_bound" , # Is this a bound method?
18311833 "def_extras" , # Information about original definition we want to serialize.
18321834 # This is used for more detailed error messages.
18331835 "type_guard" , # T, if -> TypeGuard[T] (ret_type is bool in this case).
@@ -1855,7 +1857,7 @@ def __init__(
18551857 implicit : bool = False ,
18561858 special_sig : str | None = None ,
18571859 from_type_type : bool = False ,
1858- bound_args : Sequence [ Type | None ] = () ,
1860+ is_bound : bool = False ,
18591861 def_extras : dict [str , Any ] | None = None ,
18601862 type_guard : Type | None = None ,
18611863 type_is : Type | None = None ,
@@ -1888,9 +1890,7 @@ def __init__(
18881890 self .from_type_type = from_type_type
18891891 self .from_concatenate = from_concatenate
18901892 self .imprecise_arg_kinds = imprecise_arg_kinds
1891- if not bound_args :
1892- bound_args = ()
1893- self .bound_args = bound_args
1893+ self .is_bound = is_bound
18941894 if def_extras :
18951895 self .def_extras = def_extras
18961896 elif isinstance (definition , FuncDef ):
@@ -1927,7 +1927,7 @@ def copy_modified(
19271927 implicit : Bogus [bool ] = _dummy ,
19281928 special_sig : Bogus [str | None ] = _dummy ,
19291929 from_type_type : Bogus [bool ] = _dummy ,
1930- bound_args : Bogus [list [ Type | None ] ] = _dummy ,
1930+ is_bound : Bogus [bool ] = _dummy ,
19311931 def_extras : Bogus [dict [str , Any ]] = _dummy ,
19321932 type_guard : Bogus [Type | None ] = _dummy ,
19331933 type_is : Bogus [Type | None ] = _dummy ,
@@ -1952,7 +1952,7 @@ def copy_modified(
19521952 implicit = implicit if implicit is not _dummy else self .implicit ,
19531953 special_sig = special_sig if special_sig is not _dummy else self .special_sig ,
19541954 from_type_type = from_type_type if from_type_type is not _dummy else self .from_type_type ,
1955- bound_args = bound_args if bound_args is not _dummy else self .bound_args ,
1955+ is_bound = is_bound if is_bound is not _dummy else self .is_bound ,
19561956 def_extras = def_extras if def_extras is not _dummy else dict (self .def_extras ),
19571957 type_guard = type_guard if type_guard is not _dummy else self .type_guard ,
19581958 type_is = type_is if type_is is not _dummy else self .type_is ,
@@ -2277,7 +2277,7 @@ def serialize(self) -> JsonDict:
22772277 "variables" : [v .serialize () for v in self .variables ],
22782278 "is_ellipsis_args" : self .is_ellipsis_args ,
22792279 "implicit" : self .implicit ,
2280- "bound_args " : [( None if t is None else t . serialize ()) for t in self .bound_args ] ,
2280+ "is_bound " : self .is_bound ,
22812281 "def_extras" : dict (self .def_extras ),
22822282 "type_guard" : self .type_guard .serialize () if self .type_guard is not None else None ,
22832283 "type_is" : (self .type_is .serialize () if self .type_is is not None else None ),
@@ -2300,7 +2300,7 @@ def deserialize(cls, data: JsonDict) -> CallableType:
23002300 variables = [cast (TypeVarLikeType , deserialize_type (v )) for v in data ["variables" ]],
23012301 is_ellipsis_args = data ["is_ellipsis_args" ],
23022302 implicit = data ["implicit" ],
2303- bound_args = [( None if t is None else deserialize_type ( t )) for t in data ["bound_args" ] ],
2303+ is_bound = data ["is_bound" ],
23042304 def_extras = data ["def_extras" ],
23052305 type_guard = (
23062306 deserialize_type (data ["type_guard" ]) if data ["type_guard" ] is not None else None
0 commit comments