59
59
ArgumentDefinition ,
60
60
EnvironmentVariableDefinition ,
61
61
GlobalVariableDefinition ,
62
+ InvalidVariableError ,
62
63
LibraryEntry ,
63
64
LocalVariableDefinition ,
64
65
TestVariableDefinition ,
@@ -1185,7 +1186,7 @@ def _visit_Arguments(self, node: Statement) -> None: # noqa: N802
1185
1186
)
1186
1187
)
1187
1188
1188
- except VariableError :
1189
+ except ( VariableError , InvalidVariableError ) :
1189
1190
pass
1190
1191
1191
1192
def _analyze_assign_statement (self , node : Statement ) -> None :
@@ -1225,7 +1226,7 @@ def _analyze_assign_statement(self, node: Statement) -> None:
1225
1226
)
1226
1227
)
1227
1228
1228
- except VariableError :
1229
+ except ( VariableError , InvalidVariableError ) :
1229
1230
pass
1230
1231
1231
1232
def visit_InlineIfHeader (self , node : Statement ) -> None : # noqa: N802
@@ -1239,7 +1240,7 @@ def visit_ForHeader(self, node: Statement) -> None: # noqa: N802
1239
1240
variables = node .get_tokens (Token .VARIABLE )
1240
1241
for variable in variables :
1241
1242
variable_token = self ._get_variable_token (variable )
1242
- if variable_token is not None :
1243
+ if variable_token is not None and is_variable ( variable_token . value ) :
1243
1244
existing_var = self ._find_variable (variable_token .value )
1244
1245
1245
1246
if existing_var is None or existing_var .type not in [
@@ -1301,7 +1302,7 @@ def visit_ExceptHeader(self, node: Statement) -> None: # noqa: N802
1301
1302
source = self ._namespace .source ,
1302
1303
)
1303
1304
1304
- except VariableError :
1305
+ except ( VariableError , InvalidVariableError ) :
1305
1306
pass
1306
1307
1307
1308
def _format_template (self , template : str , arguments : Tuple [str , ...]) -> Tuple [str , Tuple [str , ...]]:
@@ -1615,9 +1616,12 @@ def _find_variable(self, name: str) -> Optional[VariableDefinition]:
1615
1616
else self ._suite_variables if self ._in_setting else self ._variables
1616
1617
)
1617
1618
1618
- matcher = VariableMatcher (name )
1619
+ try :
1620
+ matcher = VariableMatcher (name )
1619
1621
1620
- return vars .get (matcher , None )
1622
+ return vars .get (matcher , None )
1623
+ except (VariableError , InvalidVariableError ):
1624
+ return None
1621
1625
1622
1626
def _is_number (self , name : str ) -> bool :
1623
1627
if name .startswith ("$" ):
0 commit comments