@@ -5078,7 +5078,7 @@ def partition_by_callable(
50785078 callables , uncallables = self .partition_by_callable (
50795079 erase_to_union_or_bound (typ ), unsound_partition
50805080 )
5081- uncallables = [typ ] if len ( uncallables ) else []
5081+ uncallables = [typ ] if uncallables else []
50825082 return callables , uncallables
50835083
50845084 # A TupleType is callable if its fallback is, but needs special handling
@@ -5093,7 +5093,7 @@ def partition_by_callable(
50935093 callables , uncallables = self .partition_by_callable (
50945094 method .type , unsound_partition = False
50955095 )
5096- if len ( callables ) and not len ( uncallables ) :
5096+ if callables and not uncallables :
50975097 # Only consider the type callable if its __call__ method is
50985098 # definitely callable.
50995099 return [typ ], []
@@ -5129,14 +5129,12 @@ def conditional_callable_type_map(
51295129
51305130 callables , uncallables = self .partition_by_callable (current_type , unsound_partition = False )
51315131
5132- if len (callables ) and len (uncallables ):
5133- callable_map = {expr : UnionType .make_union (callables )} if len (callables ) else None
5134- uncallable_map = (
5135- {expr : UnionType .make_union (uncallables )} if len (uncallables ) else None
5136- )
5132+ if callables and uncallables :
5133+ callable_map = {expr : UnionType .make_union (callables )} if callables else None
5134+ uncallable_map = {expr : UnionType .make_union (uncallables )} if uncallables else None
51375135 return callable_map , uncallable_map
51385136
5139- elif len ( callables ) :
5137+ elif callables :
51405138 return {}, None
51415139
51425140 return None , {}
@@ -6511,7 +6509,7 @@ def conditional_types_with_intersection(
65116509 if intersection is None :
65126510 continue
65136511 out .append (intersection )
6514- if len ( out ) == 0 :
6512+ if not out :
65156513 # Only report errors if no element in the union worked.
65166514 if self .should_report_unreachable_issues ():
65176515 for types , reason in errors :
@@ -7351,7 +7349,7 @@ def add_mapping(self, keys: set[TKey], values: set[TValue]) -> None:
73517349
73527350 Note that the given set of keys must be non-empty -- otherwise, nothing happens.
73537351 """
7354- if len ( keys ) == 0 :
7352+ if not keys :
73557353 return
73567354
73577355 subtree_roots = [self ._lookup_or_make_root_id (key ) for key in keys ]
@@ -7462,7 +7460,7 @@ def group_comparison_operands(
74627460 if current_indices and (operator != last_operator or operator not in operators_to_group ):
74637461 # If some of the operands in the chain are assignable, defer adding it: we might
74647462 # end up needing to merge it with other chains that appear later.
7465- if len ( current_hashes ) == 0 :
7463+ if not current_hashes :
74667464 simplified_operator_list .append ((last_operator , sorted (current_indices )))
74677465 else :
74687466 groups [last_operator ].add_mapping (current_hashes , current_indices )
@@ -7485,7 +7483,7 @@ def group_comparison_operands(
74857483 current_hashes .add (right_hash )
74867484
74877485 if last_operator is not None :
7488- if len ( current_hashes ) == 0 :
7486+ if not current_hashes :
74897487 simplified_operator_list .append ((last_operator , sorted (current_indices )))
74907488 else :
74917489 groups [last_operator ].add_mapping (current_hashes , current_indices )
0 commit comments