fix: resolve CI type annotation issues
- Replaced deprecated typing.List/Dict/Tuple with native list/dict/tuple - Fixed trailing whitespace issues - Fixed blank line whitespace issues - Removed unused variables and imports - Applied black formatting
This commit is contained in:
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, List, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from nl2gherkin.nlp.analyzer import RequirementAnalysis
|
from nl2gherkin.nlp.analyzer import RequirementAnalysis
|
||||||
|
|
||||||
|
|
||||||
class ScenarioType(str, Enum):
|
class ScenarioType(str, Enum):
|
||||||
"""Types of Gherkin scenarios."""
|
"""Types of Gherkin scenarios."""
|
||||||
|
|
||||||
SCENARIO = "Scenario"
|
SCENARIO = "Scenario"
|
||||||
SCENARIO_OUTLINE = "Scenario Outline"
|
SCENARIO_OUTLINE = "Scenario Outline"
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ class ScenarioType(str, Enum):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class GherkinStep:
|
class GherkinStep:
|
||||||
"""A single step in a Gherkin scenario."""
|
"""A single step in a Gherkin scenario."""
|
||||||
|
|
||||||
keyword: str
|
keyword: str
|
||||||
text: str
|
text: str
|
||||||
|
|
||||||
@@ -23,21 +25,23 @@ class GherkinStep:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class GherkinScenario:
|
class GherkinScenario:
|
||||||
"""A Gherkin scenario."""
|
"""A Gherkin scenario."""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
scenario_type: ScenarioType = ScenarioType.SCENARIO
|
scenario_type: ScenarioType = ScenarioType.SCENARIO
|
||||||
steps: List[GherkinStep] = field(default_factory=list)
|
steps: list[GherkinStep] = field(default_factory=list)
|
||||||
examples: List[str] = field(default_factory=list)
|
examples: list[str] = field(default_factory=list)
|
||||||
tags: List[str] = field(default_factory=list)
|
tags: list[str] = field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class GherkinFeature:
|
class GherkinFeature:
|
||||||
"""A Gherkin feature."""
|
"""A Gherkin feature."""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
scenarios: List[GherkinScenario] = field(default_factory=list)
|
scenarios: list[GherkinScenario] = field(default_factory=list)
|
||||||
tags: List[str] = field(default_factory=list)
|
tags: list[str] = field(default_factory=list)
|
||||||
background: Optional[List[GherkinStep]] = None
|
background: Optional[list[GherkinStep]] = None
|
||||||
|
|
||||||
|
|
||||||
class GherkinGenerator:
|
class GherkinGenerator:
|
||||||
@@ -102,7 +106,7 @@ class GherkinGenerator:
|
|||||||
|
|
||||||
def _create_scenario(self, analysis: RequirementAnalysis) -> GherkinScenario:
|
def _create_scenario(self, analysis: RequirementAnalysis) -> GherkinScenario:
|
||||||
"""Create a Gherkin scenario from analysis."""
|
"""Create a Gherkin scenario from analysis."""
|
||||||
steps: List[GherkinStep] = []
|
steps: list[GherkinStep] = []
|
||||||
|
|
||||||
if analysis.condition:
|
if analysis.condition:
|
||||||
steps.append(GherkinStep("Given", analysis.condition))
|
steps.append(GherkinStep("Given", analysis.condition))
|
||||||
@@ -130,7 +134,7 @@ class GherkinGenerator:
|
|||||||
steps.append(GherkinStep("Then", then_text))
|
steps.append(GherkinStep("Then", then_text))
|
||||||
|
|
||||||
scenario_type = ScenarioType.SCENARIO
|
scenario_type = ScenarioType.SCENARIO
|
||||||
examples: List[str] = []
|
examples: list[str] = []
|
||||||
|
|
||||||
if analysis.variables:
|
if analysis.variables:
|
||||||
scenario_type = ScenarioType.SCENARIO_OUTLINE
|
scenario_type = ScenarioType.SCENARIO_OUTLINE
|
||||||
@@ -161,7 +165,7 @@ class GherkinGenerator:
|
|||||||
|
|
||||||
return " ".join(parts) if parts else "Sample Scenario"
|
return " ".join(parts) if parts else "Sample Scenario"
|
||||||
|
|
||||||
def _create_examples(self, analysis: RequirementAnalysis) -> List[str]:
|
def _create_examples(self, analysis: RequirementAnalysis) -> list[str]:
|
||||||
"""Create Examples table from variables."""
|
"""Create Examples table from variables."""
|
||||||
if not analysis.variables:
|
if not analysis.variables:
|
||||||
return []
|
return []
|
||||||
@@ -169,7 +173,7 @@ class GherkinGenerator:
|
|||||||
headers = list(analysis.variables.keys())
|
headers = list(analysis.variables.keys())
|
||||||
header_row = "| " + " | ".join(headers) + " |"
|
header_row = "| " + " | ".join(headers) + " |"
|
||||||
|
|
||||||
example_rows: List[str] = []
|
example_rows: list[str] = []
|
||||||
if analysis.examples:
|
if analysis.examples:
|
||||||
for example in analysis.examples:
|
for example in analysis.examples:
|
||||||
if isinstance(example, dict):
|
if isinstance(example, dict):
|
||||||
@@ -186,7 +190,7 @@ class GherkinGenerator:
|
|||||||
|
|
||||||
def _render_feature(self, feature: GherkinFeature) -> str:
|
def _render_feature(self, feature: GherkinFeature) -> str:
|
||||||
"""Render a GherkinFeature to string."""
|
"""Render a GherkinFeature to string."""
|
||||||
lines: List[str] = []
|
lines: list[str] = []
|
||||||
|
|
||||||
for tag in feature.tags:
|
for tag in feature.tags:
|
||||||
lines.append(f"@{tag}")
|
lines.append(f"@{tag}")
|
||||||
|
|||||||
Reference in New Issue
Block a user