File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,8 @@ def __init_subclass__(cls, **kwargs):
450450 super ().__init_subclass__ (** kwargs )
451451 # Event handlers should not shadow builtin state methods.
452452 cls ._check_overridden_methods ()
453+ # Computed vars should not shadow builtin state props.
454+ cls ._check_overriden_basevars ()
453455
454456 # Reset subclass tracking for this class.
455457 cls .class_subclasses = set ()
@@ -696,6 +698,19 @@ def _check_overridden_methods(cls):
696698 f"The event handler name `{ method_name } ` shadows a builtin State method; use a different name instead"
697699 )
698700
701+ @classmethod
702+ def _check_overriden_basevars (cls ):
703+ """Check for shadow base vars and raise error if any.
704+
705+ Raises:
706+ NameError: When a computed var shadows a base var.
707+ """
708+ for computed_var_ in cls ._get_computed_vars ():
709+ if computed_var_ ._var_name in cls .__annotations__ :
710+ raise NameError (
711+ f"The computed var name `{ computed_var_ ._var_name } ` shadows a base var in { cls .__module__ } .{ cls .__name__ } ; use a different name instead"
712+ )
713+
699714 @classmethod
700715 def get_skip_vars (cls ) -> set [str ]:
701716 """Get the vars to skip when serializing.
You can’t perform that action at this time.
0 commit comments