@@ -623,14 +623,21 @@ def _process_class(cls, repr, eq, order, unsafe_hash, init, frozen):
623623 else :
624624 setattr (cls , f .name , f .default )
625625
626+ # We're inheriting from a frozen dataclass, but we're not frozen.
627+ if cls .__setattr__ is _frozen_setattr and not frozen :
628+ raise TypeError ('cannot inherit non-frozen dataclass from a '
629+ 'frozen one' )
630+
631+ # We're inheriting from a non-frozen dataclass, but we're frozen.
632+ if (hasattr (cls , _MARKER ) and cls .__setattr__ is not _frozen_setattr
633+ and frozen ):
634+ raise TypeError ('cannot inherit frozen dataclass from a '
635+ 'non-frozen one' )
636+
626637 # Remember all of the fields on our class (including bases). This
627638 # marks this class as being a dataclass.
628639 setattr (cls , _MARKER , fields )
629640
630- # We also need to check if a parent class is frozen: frozen has to
631- # be inherited down.
632- is_frozen = frozen or cls .__setattr__ is _frozen_setattr
633-
634641 # Was this class defined with an explicit __hash__? Note that if
635642 # __eq__ is defined in this class, then python will automatically
636643 # set __hash__ to None. This is a heuristic, as it's possible
@@ -654,7 +661,7 @@ def _process_class(cls, repr, eq, order, unsafe_hash, init, frozen):
654661 if f ._field_type in (_FIELD , _FIELD_INITVAR )]
655662 _set_new_attribute (cls , '__init__' ,
656663 _init_fn (flds ,
657- is_frozen ,
664+ frozen ,
658665 has_post_init ,
659666 # The name to use for the "self" param
660667 # in __init__. Use "self" if possible.
@@ -696,7 +703,7 @@ def _process_class(cls, repr, eq, order, unsafe_hash, init, frozen):
696703 f'in class { cls .__name__ } . Consider using '
697704 'functools.total_ordering' )
698705
699- if is_frozen :
706+ if frozen :
700707 for name , fn in [('__setattr__' , _frozen_setattr ),
701708 ('__delattr__' , _frozen_delattr )]:
702709 if _set_new_attribute (cls , name , fn ):
0 commit comments