@@ -141,30 +141,31 @@ class ExpressionInfo:
141141 - errors: list
142142 - If there were errors validating a license expression,
143143 the error messages will be appended here.
144- - invalid_keys : list
144+ - invalid_symbols : list
145145 - If the license expression that has been passed into `validate()` has
146146 license keys that are invalid (either that they are unknown or not used
147- in the right context), then those keys will be appended here.
147+ in the right context), or the syntax is incorrect because an invalid
148+ symbol was used, then those symbols will be appended here.
148149 """
149150 def __init__ (
150151 self ,
151152 original_expression ,
152153 normalized_expression = None ,
153154 errors = None ,
154- invalid_keys = None ,
155+ invalid_symbols = None ,
155156 ):
156157 self .original_expression = original_expression
157158 self .normalized_expression = normalized_expression
158159 self .errors = errors or []
159- self .invalid_keys = invalid_keys or []
160+ self .invalid_symbols = invalid_symbols or []
160161
161162 def __repr__ (self ):
162163 return (
163164 'ExpressionInfo(\n '
164165 f' original_expression={ self .original_expression !r} ,\n '
165166 f' normalized_expression={ self .normalized_expression !r} ,\n '
166167 f' errors={ self .errors !r} ,\n '
167- f' invalid_keys ={ self .invalid_keys !r} \n '
168+ f' invalid_symbols ={ self .invalid_symbols !r} \n '
168169 ')'
169170 )
170171
@@ -684,8 +685,8 @@ def validate(self, expression, strict=True, **kwargs):
684685 If an error was encountered when validating `expression`,
685686 `ExpressionInfo.errors` will be populated with strings containing the
686687 error message that has occured. If an error has occured due to unknown
687- license keys, the offending keys will be present in
688- `ExpressionInfo.invalid_keys `
688+ license keys or an invalid license symbol , the offending keys or symbols
689+ will be present in `ExpressionInfo.invalid_symbols `
689690
690691 If `strict` is True, validation error messages will be included if in a "WITH"
691692 expression such as "XXX with ZZZ" if the XXX symbol has `is_exception`
@@ -701,11 +702,7 @@ def validate(self, expression, strict=True, **kwargs):
701702 parsed_expression = self .parse (expression , strict = strict )
702703 except ExpressionError as e :
703704 expression_info .errors .append (str (e ))
704- error_code = e .error_code
705- # If we have these error codes, then we have a problematic license
706- # key that we need to append to `invalid_keys`
707- if error_code and error_code in (PARSE_INVALID_EXCEPTION , PARSE_INVALID_SYMBOL_AS_EXCEPTION ):
708- expression_info .invalid_keys .append (e .token_string )
705+ expression_info .invalid_symbols .append (e .token_string )
709706 return expression_info
710707
711708 # Check `expression` keys (validate)
@@ -714,13 +711,13 @@ def validate(self, expression, strict=True, **kwargs):
714711 except ExpressionError as e :
715712 expression_info .errors .append (str (e ))
716713 unknown_keys = self .unknown_license_keys (expression )
717- expression_info .invalid_keys .extend (unknown_keys )
714+ expression_info .invalid_symbols .extend (unknown_keys )
718715 return expression_info
719716
720717 # If we have not hit an exception, set `normalized_expression` in
721718 # `expression_info` only if we did not encounter any errors
722719 # along the way
723- if not expression_info .errors and not expression_info .invalid_keys :
720+ if not expression_info .errors and not expression_info .invalid_symbols :
724721 expression_info .normalized_expression = str (parsed_expression )
725722 return expression_info
726723
0 commit comments