10
10
11
11
from .exceptions import StepError
12
12
from .gherkin_parser import Background as GherkinBackground
13
- from .gherkin_parser import DataTable
13
+ from .gherkin_parser import DataTable , GherkinDocument , get_gherkin_document
14
14
from .gherkin_parser import Feature as GherkinFeature
15
- from .gherkin_parser import GherkinDocument
16
15
from .gherkin_parser import Rule as GherkinRule
17
16
from .gherkin_parser import Scenario as GherkinScenario
18
17
from .gherkin_parser import Step as GherkinStep
19
18
from .gherkin_parser import Tag as GherkinTag
20
- from .gherkin_parser import get_gherkin_document
21
19
from .types import STEP_TYPE_BY_PARSER_KEYWORD
22
20
23
21
PARAM_RE = re .compile (r"<(.+?)>" )
@@ -48,7 +46,7 @@ def get_tag_names(tag_data: list[GherkinTag]) -> set[str]:
48
46
"""Extract tag names from tag data.
49
47
50
48
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.
52
50
53
51
Returns:
54
52
set[str]: A set of tag names.
@@ -66,7 +64,7 @@ class Feature:
66
64
rel_filename (str): The relative path of the feature file.
67
65
name (str): The name of the feature.
68
66
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.
70
68
line_number (int): The line number where the feature starts in the file.
71
69
description (str): The description of the feature.
72
70
"""
@@ -88,10 +86,10 @@ class Examples:
88
86
"""Represents examples used in scenarios for parameterization.
89
87
90
88
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.
95
93
"""
96
94
97
95
line_number : int | None = None
@@ -154,11 +152,11 @@ class ScenarioTemplate:
154
152
name (str): The name of the scenario.
155
153
line_number (int): The line number where the scenario starts in the file.
156
154
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.
158
156
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).
162
160
"""
163
161
164
162
feature : Feature
@@ -197,7 +195,7 @@ def steps(self) -> list[Step]:
197
195
"""Get all steps for the scenario, including background steps.
198
196
199
197
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.
201
199
"""
202
200
return self .all_background_steps + self ._steps
203
201
@@ -244,8 +242,8 @@ class Scenario:
244
242
keyword (str): The keyword used to define the scenario.
245
243
name (str): The name of the scenario.
246
244
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.
249
247
tags (set[str]): A set of tags associated with the scenario.
250
248
"""
251
249
@@ -270,8 +268,8 @@ class Step:
270
268
indent (int): The indentation level of the step.
271
269
keyword (str): The keyword used for the step (e.g., 'Given', 'When', 'Then').
272
270
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).
275
273
"""
276
274
277
275
type : str
@@ -346,7 +344,7 @@ class Background:
346
344
347
345
Attributes:
348
346
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.
350
348
"""
351
349
352
350
line_number : int
@@ -371,7 +369,7 @@ class FeatureParser:
371
369
encoding (str): File encoding of the feature file to parse.
372
370
"""
373
371
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 :
375
373
self .abs_filename = os .path .abspath (os .path .join (basedir , filename ))
376
374
self .rel_filename = os .path .join (os .path .basename (basedir ), filename )
377
375
self .encoding = encoding
@@ -380,10 +378,10 @@ def parse_steps(self, steps_data: list[GherkinStep]) -> list[Step]:
380
378
"""Parse a list of step data into Step objects.
381
379
382
380
Args:
383
- steps_data (List [dict]): The list of step data.
381
+ steps_data (list [dict]): The list of step data.
384
382
385
383
Returns:
386
- List [Step]: A list of Step objects.
384
+ list [Step]: A list of Step objects.
387
385
"""
388
386
389
387
if not steps_data :
@@ -423,7 +421,7 @@ def parse_scenario(
423
421
Args:
424
422
scenario_data (dict): The dictionary containing scenario data.
425
423
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)
427
425
428
426
Returns:
429
427
ScenarioTemplate: A ScenarioTemplate object representing the parsed scenario.
0 commit comments