216216 is_literal_type ,
217217 is_named_instance ,
218218)
219- from mypy .types_utils import is_optional , remove_optional , store_argument_type , strip_type
219+ from mypy .types_utils import is_overlapping_none , remove_optional , store_argument_type , strip_type
220220from mypy .typetraverser import TypeTraverserVisitor
221221from mypy .typevars import fill_typevars , fill_typevars_with_any , has_no_typevars
222222from mypy .util import is_dunder , is_sunder , is_typeshed_file
@@ -5660,13 +5660,13 @@ def has_no_custom_eq_checks(t: Type) -> bool:
56605660
56615661 if left_index in narrowable_operand_index_to_hash :
56625662 # We only try and narrow away 'None' for now
5663- if is_optional (item_type ):
5663+ if is_overlapping_none (item_type ):
56645664 collection_item_type = get_proper_type (
56655665 builtin_item_type (iterable_type )
56665666 )
56675667 if (
56685668 collection_item_type is not None
5669- and not is_optional (collection_item_type )
5669+ and not is_overlapping_none (collection_item_type )
56705670 and not (
56715671 isinstance (collection_item_type , Instance )
56725672 and collection_item_type .type .fullname == "builtins.object"
@@ -6073,7 +6073,7 @@ def refine_away_none_in_comparison(
60736073 non_optional_types = []
60746074 for i in chain_indices :
60756075 typ = operand_types [i ]
6076- if not is_optional (typ ):
6076+ if not is_overlapping_none (typ ):
60776077 non_optional_types .append (typ )
60786078
60796079 # Make sure we have a mixture of optional and non-optional types.
@@ -6083,7 +6083,7 @@ def refine_away_none_in_comparison(
60836083 if_map = {}
60846084 for i in narrowable_operand_indices :
60856085 expr_type = operand_types [i ]
6086- if not is_optional (expr_type ):
6086+ if not is_overlapping_none (expr_type ):
60876087 continue
60886088 if any (is_overlapping_erased_types (expr_type , t ) for t in non_optional_types ):
60896089 if_map [operands [i ]] = remove_optional (expr_type )
0 commit comments