@@ -1471,7 +1471,7 @@ def accept(self, visitor: TypeVisitor[T]) -> T:
14711471
14721472 def __hash__ (self ) -> int :
14731473 if self ._hash == - 1 :
1474- self ._hash = hash ((self .type , self .args , self .last_known_value ))
1474+ self ._hash = hash ((self .type , self .args , self .last_known_value , self . extra_attrs ))
14751475 return self ._hash
14761476
14771477 def __eq__ (self , other : object ) -> bool :
@@ -2895,7 +2895,6 @@ class UnionType(ProperType):
28952895
28962896 __slots__ = (
28972897 "items" ,
2898- "_frozen_items" ,
28992898 "is_evaluated" ,
29002899 "uses_pep604_syntax" ,
29012900 "original_str_expr" ,
@@ -2915,7 +2914,6 @@ def __init__(
29152914 # We must keep this false to avoid crashes during semantic analysis.
29162915 # TODO: maybe switch this to True during type-checking pass?
29172916 self .items = flatten_nested_unions (items , handle_type_alias_type = False )
2918- self ._frozen_items = frozenset (self .items )
29192917 # is_evaluated should be set to false for type comments and string literals
29202918 self .is_evaluated = is_evaluated
29212919 # uses_pep604_syntax is True if Union uses OR syntax (X | Y)
@@ -2933,14 +2931,14 @@ def can_be_false_default(self) -> bool:
29332931 return any (item .can_be_false for item in self .items )
29342932
29352933 def __hash__ (self ) -> int :
2936- return hash (self ._frozen_items )
2934+ return hash (frozenset ( self .items ) )
29372935
29382936 def __eq__ (self , other : object ) -> bool :
29392937 if not isinstance (other , UnionType ):
29402938 return NotImplemented
29412939 if self is other :
29422940 return True
2943- return self ._frozen_items == other ._frozen_items
2941+ return frozenset ( self .items ) == frozenset ( other .items )
29442942
29452943 @overload
29462944 @staticmethod
0 commit comments