@@ -776,33 +776,35 @@ def _lint_attribute_name(
776776 """Check an attribute name for deprecations and validity according to the
777777 surrounding promise type."""
778778 assert node .type == "attribute_name"
779- if state .strict and state .promise_type == "vars" and _text (node ) == "str" :
779+ attribute_name = _text (node )
780+ assert attribute_name == state .attribute_name
781+ if state .strict and state .promise_type == "vars" and attribute_name == "str" :
780782 raise ValidationError (
781783 f"Deprecation: Use 'string' instead of 'str' { location } " , node
782784 )
783- if state .strict and _text ( node ) == "ifvarclass" :
785+ if state .strict and attribute_name == "ifvarclass" :
784786 raise ValidationError (
785787 f"Deprecation: Use 'if' instead of 'ifvarclass' { location } " , node
786788 )
787- if state .promise_type and state . attribute_name :
789+ if state .promise_type and attribute_name :
788790 promise_type_data = syntax_data .BUILTIN_PROMISE_TYPES .get (
789791 state .promise_type , {}
790792 )
791793 if not promise_type_data :
792794 # Custom promise type - we cannot validate attribute name here.
793795 return
794796 promise_type_attrs = promise_type_data .get ("attributes" , {})
795- if state . attribute_name not in promise_type_attrs :
797+ if attribute_name not in promise_type_attrs :
796798 raise ValidationError (
797- f"Error: Invalid attribute '{ state . attribute_name } ' for promise type '{ state .promise_type } ' { location } " ,
799+ f"Error: Invalid attribute '{ attribute_name } ' for promise type '{ state .promise_type } ' { location } " ,
798800 node ,
799801 )
800- if state .block_keyword == "promise" and state . attribute_name not in (
802+ if state .block_keyword == "promise" and attribute_name not in (
801803 None ,
802804 * PROMISE_BLOCK_ATTRIBUTES ,
803805 ):
804806 raise ValidationError (
805- f"Error: Invalid attribute name '{ state . attribute_name } ' in '{ state .block_name } ' custom promise type definition { location } " ,
807+ f"Error: Invalid attribute name '{ attribute_name } ' in '{ state .block_name } ' custom promise type definition { location } " ,
806808 node ,
807809 )
808810
0 commit comments