@@ -1597,6 +1597,9 @@ def with_name(self, name: str) -> FunctionLike:
1597
1597
def get_name (self ) -> str | None :
1598
1598
pass
1599
1599
1600
+ def bound (self ) -> bool :
1601
+ return bool (self .items ) and self .items [0 ].is_bound
1602
+
1600
1603
1601
1604
class FormalArgument (NamedTuple ):
1602
1605
name : str | None
@@ -1826,8 +1829,7 @@ class CallableType(FunctionLike):
1826
1829
# 'dict' and 'partial' for a `functools.partial` evaluation)
1827
1830
"from_type_type" , # Was this callable generated by analyzing Type[...]
1828
1831
# 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?
1831
1833
"def_extras" , # Information about original definition we want to serialize.
1832
1834
# This is used for more detailed error messages.
1833
1835
"type_guard" , # T, if -> TypeGuard[T] (ret_type is bool in this case).
@@ -1855,7 +1857,7 @@ def __init__(
1855
1857
implicit : bool = False ,
1856
1858
special_sig : str | None = None ,
1857
1859
from_type_type : bool = False ,
1858
- bound_args : Sequence [ Type | None ] = () ,
1860
+ is_bound : bool = False ,
1859
1861
def_extras : dict [str , Any ] | None = None ,
1860
1862
type_guard : Type | None = None ,
1861
1863
type_is : Type | None = None ,
@@ -1888,9 +1890,7 @@ def __init__(
1888
1890
self .from_type_type = from_type_type
1889
1891
self .from_concatenate = from_concatenate
1890
1892
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
1894
1894
if def_extras :
1895
1895
self .def_extras = def_extras
1896
1896
elif isinstance (definition , FuncDef ):
@@ -1927,7 +1927,7 @@ def copy_modified(
1927
1927
implicit : Bogus [bool ] = _dummy ,
1928
1928
special_sig : Bogus [str | None ] = _dummy ,
1929
1929
from_type_type : Bogus [bool ] = _dummy ,
1930
- bound_args : Bogus [list [ Type | None ] ] = _dummy ,
1930
+ is_bound : Bogus [bool ] = _dummy ,
1931
1931
def_extras : Bogus [dict [str , Any ]] = _dummy ,
1932
1932
type_guard : Bogus [Type | None ] = _dummy ,
1933
1933
type_is : Bogus [Type | None ] = _dummy ,
@@ -1952,7 +1952,7 @@ def copy_modified(
1952
1952
implicit = implicit if implicit is not _dummy else self .implicit ,
1953
1953
special_sig = special_sig if special_sig is not _dummy else self .special_sig ,
1954
1954
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 ,
1956
1956
def_extras = def_extras if def_extras is not _dummy else dict (self .def_extras ),
1957
1957
type_guard = type_guard if type_guard is not _dummy else self .type_guard ,
1958
1958
type_is = type_is if type_is is not _dummy else self .type_is ,
@@ -2277,7 +2277,7 @@ def serialize(self) -> JsonDict:
2277
2277
"variables" : [v .serialize () for v in self .variables ],
2278
2278
"is_ellipsis_args" : self .is_ellipsis_args ,
2279
2279
"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 ,
2281
2281
"def_extras" : dict (self .def_extras ),
2282
2282
"type_guard" : self .type_guard .serialize () if self .type_guard is not None else None ,
2283
2283
"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:
2300
2300
variables = [cast (TypeVarLikeType , deserialize_type (v )) for v in data ["variables" ]],
2301
2301
is_ellipsis_args = data ["is_ellipsis_args" ],
2302
2302
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" ],
2304
2304
def_extras = data ["def_extras" ],
2305
2305
type_guard = (
2306
2306
deserialize_type (data ["type_guard" ]) if data ["type_guard" ] is not None else None
0 commit comments