11from __future__ import annotations
22
3- from typing import NamedTuple , Optional , Callable
3+ from typing import NamedTuple , Optional , Callable , List
44
55from cucumber_expressions .ast import Token , TokenType , Node , NodeType
66from cucumber_expressions .errors import (
@@ -18,7 +18,7 @@ class Result(NamedTuple):
1818
1919class Parser (NamedTuple ):
2020 expression : str
21- tokens : list [Token ]
21+ tokens : List [Token ]
2222 current : int
2323
2424
@@ -75,7 +75,7 @@ def parse(self, expression: str) -> Node:
7575
7676 # optional := '(' + option* + ')'
7777 # option := optional | parameter | text
78- optional_sub_parsers : list = []
78+ optional_sub_parsers = []
7979 parse_optional = self .parse_between (
8080 NodeType .OPTIONAL ,
8181 TokenType .BEGIN_OPTIONAL ,
@@ -170,7 +170,7 @@ def parse_between(
170170 ast_type : NodeType ,
171171 begin_token : TokenType ,
172172 end_token : TokenType ,
173- parsers : list ,
173+ parsers : List ,
174174 ) -> Callable [[Parser ], Result | tuple [int , Node ]]:
175175 def _parse_between (parser : Parser ):
176176 if not self .looking_at (parser .tokens , parser .current , begin_token ):
@@ -205,7 +205,7 @@ def _parse_between(parser: Parser):
205205
206206 @staticmethod
207207 def parse_token (
208- expression , parsers : list , tokens : list [Token ], start_at : int
208+ expression , parsers : List , tokens : List [Token ], start_at : int
209209 ) -> Result :
210210 for parser in parsers :
211211 consumed , ast = parser (Parser (expression , tokens , start_at ))
@@ -217,14 +217,14 @@ def parse_token(
217217 def parse_tokens_until (
218218 self ,
219219 expression ,
220- parsers : list ,
221- tokens : list [Token ],
220+ parsers : List ,
221+ tokens : List [Token ],
222222 start_at : int ,
223- end_tokens : list [TokenType ],
224- ) -> tuple [int , list [Node ]]:
223+ end_tokens : List [TokenType ],
224+ ) -> tuple [int , List [Node ]]:
225225 current = start_at
226226 size = len (tokens )
227- ast : list [Node ] = []
227+ ast : List [Node ] = []
228228 while current < size :
229229 if self .looking_at_any (tokens , current , end_tokens ):
230230 break
@@ -238,14 +238,14 @@ def parse_tokens_until(
238238 return current - start_at , ast
239239
240240 def looking_at_any (
241- self , tokens : list [Token ], position : int , token_types : list [TokenType ]
241+ self , tokens : List [Token ], position : int , token_types : List [TokenType ]
242242 ) -> bool :
243243 return any (
244244 self .looking_at (tokens , position , token_type ) for token_type in token_types
245245 )
246246
247247 @staticmethod
248- def looking_at (tokens : list [Token ], position : int , token_type : TokenType ) -> bool :
248+ def looking_at (tokens : List [Token ], position : int , token_type : TokenType ) -> bool :
249249 if position < 0 :
250250 # If configured correctly this will never happen
251251 # Keep for completeness
@@ -255,8 +255,8 @@ def looking_at(tokens: list[Token], position: int, token_type: TokenType) -> boo
255255 return tokens [position ].ast_type == token_type
256256
257257 def split_alternatives (
258- self , start : int , end : int , alternation : list [Node ]
259- ) -> list [Node ]:
258+ self , start : int , end : int , alternation : List [Node ]
259+ ) -> List [Node ]:
260260 separators = []
261261 alternatives = []
262262 alternative = []
@@ -272,8 +272,8 @@ def split_alternatives(
272272
273273 @staticmethod
274274 def create_alternative_nodes (
275- start : int , end : int , separators : list , alternatives : list
276- ) -> list [Node ]:
275+ start : int , end : int , separators : List , alternatives : List
276+ ) -> List [Node ]:
277277 for index , alternative in enumerate (alternatives ):
278278 if index == 0 :
279279 right_separator = separators [index ]
0 commit comments