1010
1111from .exceptions import StepError
1212from .gherkin_parser import Background as GherkinBackground
13- from .gherkin_parser import DataTable
13+ from .gherkin_parser import DataTable , GherkinDocument , get_gherkin_document
1414from .gherkin_parser import Feature as GherkinFeature
15- from .gherkin_parser import GherkinDocument
1615from .gherkin_parser import Rule as GherkinRule
1716from .gherkin_parser import Scenario as GherkinScenario
1817from .gherkin_parser import Step as GherkinStep
1918from .gherkin_parser import Tag as GherkinTag
20- from .gherkin_parser import get_gherkin_document
2119from .types import STEP_TYPE_BY_PARSER_KEYWORD
2220
2321PARAM_RE = re .compile (r"<(.+?)>" )
@@ -48,7 +46,7 @@ def get_tag_names(tag_data: list[GherkinTag]) -> set[str]:
4846 """Extract tag names from tag data.
4947
5048 Args:
51- tag_data (List [dict]): The tag data to extract names from.
49+ tag_data (list [dict]): The tag data to extract names from.
5250
5351 Returns:
5452 set[str]: A set of tag names.
@@ -66,7 +64,7 @@ class Feature:
6664 rel_filename (str): The relative path of the feature file.
6765 name (str): The name of the feature.
6866 tags (set[str]): A set of tags associated with the feature.
69- background (Optional[ Background] ): The background steps for the feature, if any.
67+ background (Background | None ): The background steps for the feature, if any.
7068 line_number (int): The line number where the feature starts in the file.
7169 description (str): The description of the feature.
7270 """
@@ -88,10 +86,10 @@ class Examples:
8886 """Represents examples used in scenarios for parameterization.
8987
9088 Attributes:
91- line_number (Optional[ int] ): The line number where the examples start.
92- name (Optional[ str] ): The name of the examples.
93- example_params (List [str]): The names of the parameters for the examples.
94- examples (List [Sequence[str]]): The list of example rows.
89+ line_number (int | None ): The line number where the examples start.
90+ name (str | None ): The name of the examples.
91+ example_params (list [str]): The names of the parameters for the examples.
92+ examples (list [Sequence[str]]): The list of example rows.
9593 """
9694
9795 line_number : int | None = None
@@ -154,11 +152,11 @@ class ScenarioTemplate:
154152 name (str): The name of the scenario.
155153 line_number (int): The line number where the scenario starts in the file.
156154 templated (bool): Whether the scenario is templated.
157- description (Optional[ str] ): The description of the scenario.
155+ description (str | None ): The description of the scenario.
158156 tags (set[str]): A set of tags associated with the scenario.
159- _steps (List [Step]): The list of steps in the scenario (internal use only).
160- examples (Optional[ Examples] ): The examples used for parameterization in the scenario.
161- rule (Optional[ Rule] ): The rule to which the scenario may belong (None = no rule).
157+ _steps (list [Step]): The list of steps in the scenario (internal use only).
158+ examples (Examples | None ): The examples used for parameterization in the scenario.
159+ rule (Rule | None ): The rule to which the scenario may belong (None = no rule).
162160 """
163161
164162 feature : Feature
@@ -197,7 +195,7 @@ def steps(self) -> list[Step]:
197195 """Get all steps for the scenario, including background steps.
198196
199197 Returns:
200- List [Step]: A list of steps, including any background steps from the feature.
198+ list [Step]: A list of steps, including any background steps from the feature.
201199 """
202200 return self .all_background_steps + self ._steps
203201
@@ -244,8 +242,8 @@ class Scenario:
244242 keyword (str): The keyword used to define the scenario.
245243 name (str): The name of the scenario.
246244 line_number (int): The line number where the scenario starts in the file.
247- steps (List [Step]): The list of steps in the scenario.
248- description (Optional[ str] ): The description of the scenario.
245+ steps (list [Step]): The list of steps in the scenario.
246+ description (str | None ): The description of the scenario.
249247 tags (set[str]): A set of tags associated with the scenario.
250248 """
251249
@@ -270,8 +268,8 @@ class Step:
270268 indent (int): The indentation level of the step.
271269 keyword (str): The keyword used for the step (e.g., 'Given', 'When', 'Then').
272270 failed (bool): Whether the step has failed (internal use only).
273- scenario (Optional[ ScenarioTemplate] ): The scenario to which this step belongs (internal use only).
274- background (Optional[ Background] ): The background to which this step belongs (internal use only).
271+ scenario (ScenarioTemplate | None ): The scenario to which this step belongs (internal use only).
272+ background (Background | None ): The background to which this step belongs (internal use only).
275273 """
276274
277275 type : str
@@ -346,7 +344,7 @@ class Background:
346344
347345 Attributes:
348346 line_number (int): The line number where the background starts in the file.
349- steps (List [Step]): The list of steps in the background.
347+ steps (list [Step]): The list of steps in the background.
350348 """
351349
352350 line_number : int
@@ -371,7 +369,7 @@ class FeatureParser:
371369 encoding (str): File encoding of the feature file to parse.
372370 """
373371
374- def __init__ (self , basedir : str , filename : str , encoding : str = "utf-8" ):
372+ def __init__ (self , basedir : str , filename : str , encoding : str = "utf-8" ) -> None :
375373 self .abs_filename = os .path .abspath (os .path .join (basedir , filename ))
376374 self .rel_filename = os .path .join (os .path .basename (basedir ), filename )
377375 self .encoding = encoding
@@ -380,10 +378,10 @@ def parse_steps(self, steps_data: list[GherkinStep]) -> list[Step]:
380378 """Parse a list of step data into Step objects.
381379
382380 Args:
383- steps_data (List [dict]): The list of step data.
381+ steps_data (list [dict]): The list of step data.
384382
385383 Returns:
386- List [Step]: A list of Step objects.
384+ list [Step]: A list of Step objects.
387385 """
388386
389387 if not steps_data :
@@ -423,7 +421,7 @@ def parse_scenario(
423421 Args:
424422 scenario_data (dict): The dictionary containing scenario data.
425423 feature (Feature): The feature to which this scenario belongs.
426- rule (Optional[ Rule] ): The rule to which this scenario may belong. (None = no rule)
424+ rule (Rule | None ): The rule to which this scenario may belong. (None = no rule)
427425
428426 Returns:
429427 ScenarioTemplate: A ScenarioTemplate object representing the parsed scenario.
0 commit comments