@@ -130,6 +130,15 @@ class Type(mypy.nodes.Context):
130
130
"""Abstract base class for all types."""
131
131
132
132
__slots__ = ('can_be_true' , 'can_be_false' )
133
+ # 'can_be_true' and 'can_be_false' mean whether the value of the
134
+ # expression can be true or false in a boolean context. They are useful
135
+ # when inferring the type of logic expressions like `x and y`.
136
+ #
137
+ # For example:
138
+ # * the literal `False` can't be true while `True` can.
139
+ # * a value with type `bool` can be true or false.
140
+ # * `None` can't be true
141
+ # * ...
133
142
134
143
def __init__ (self , line : int = - 1 , column : int = - 1 ) -> None :
135
144
super ().__init__ (line , column )
@@ -1373,8 +1382,7 @@ class TupleType(ProperType):
1373
1382
implicit: If True, derived from a tuple expression (t,....) instead of Tuple[t, ...]
1374
1383
"""
1375
1384
1376
- __slots__ = ('items' , 'partial_fallback' , 'implicit' ,
1377
- 'can_be_true' , 'can_be_false' )
1385
+ __slots__ = ('items' , 'partial_fallback' , 'implicit' )
1378
1386
1379
1387
items : List [Type ]
1380
1388
partial_fallback : Instance
@@ -1451,8 +1459,7 @@ class TypedDictType(ProperType):
1451
1459
TODO: The fallback structure is perhaps overly complicated.
1452
1460
"""
1453
1461
1454
- __slots__ = ('items' , 'required_keys' , 'fallback' ,
1455
- 'can_be_true' , 'can_be_false' )
1462
+ __slots__ = ('items' , 'required_keys' , 'fallback' )
1456
1463
1457
1464
items : "OrderedDict[str, Type]" # item_name -> item_type
1458
1465
required_keys : Set [str ]
0 commit comments