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 enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from nl2gherkin.nlp.analyzer import RequirementAnalysis
|
||||
|
||||
|
||||
class ScenarioType(str, Enum):
|
||||
"""Types of Gherkin scenarios."""
|
||||
|
||||
SCENARIO = "Scenario"
|
||||
SCENARIO_OUTLINE = "Scenario Outline"
|
||||
|
||||
@@ -16,6 +17,7 @@ class ScenarioType(str, Enum):
|
||||
@dataclass
|
||||
class GherkinStep:
|
||||
"""A single step in a Gherkin scenario."""
|
||||
|
||||
keyword: str
|
||||
text: str
|
||||
|
||||
@@ -23,21 +25,23 @@ class GherkinStep:
|
||||
@dataclass
|
||||
class GherkinScenario:
|
||||
"""A Gherkin scenario."""
|
||||
|
||||
name: str
|
||||
scenario_type: ScenarioType = ScenarioType.SCENARIO
|
||||
steps: List[GherkinStep] = field(default_factory=list)
|
||||
examples: List[str] = field(default_factory=list)
|
||||
tags: List[str] = field(default_factory=list)
|
||||
steps: list[GherkinStep] = field(default_factory=list)
|
||||
examples: list[str] = field(default_factory=list)
|
||||
tags: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class GherkinFeature:
|
||||
"""A Gherkin feature."""
|
||||
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
scenarios: List[GherkinScenario] = field(default_factory=list)
|
||||
tags: List[str] = field(default_factory=list)
|
||||
background: Optional[List[GherkinStep]] = None
|
||||
scenarios: list[GherkinScenario] = field(default_factory=list)
|
||||
tags: list[str] = field(default_factory=list)
|
||||
background: Optional[list[GherkinStep]] = None
|
||||
|
||||
|
||||
class GherkinGenerator:
|
||||
@@ -45,7 +49,7 @@ class GherkinGenerator:
|
||||
|
||||
def __init__(self, parser: Optional[Any] = None) -> None:
|
||||
"""Initialize the generator.
|
||||
|
||||
|
||||
Args:
|
||||
parser: Optional parser for validation.
|
||||
"""
|
||||
@@ -53,10 +57,10 @@ class GherkinGenerator:
|
||||
|
||||
def generate(self, analysis: RequirementAnalysis) -> str:
|
||||
"""Generate Gherkin from a requirement analysis.
|
||||
|
||||
|
||||
Args:
|
||||
analysis: The analyzed requirement.
|
||||
|
||||
|
||||
Returns:
|
||||
Gherkin formatted string.
|
||||
"""
|
||||
@@ -65,10 +69,10 @@ class GherkinGenerator:
|
||||
|
||||
def generate_scenario(self, analysis: RequirementAnalysis) -> GherkinScenario:
|
||||
"""Generate a scenario from analysis.
|
||||
|
||||
|
||||
Args:
|
||||
analysis: The analyzed requirement.
|
||||
|
||||
|
||||
Returns:
|
||||
GherkinScenario object.
|
||||
"""
|
||||
@@ -102,7 +106,7 @@ class GherkinGenerator:
|
||||
|
||||
def _create_scenario(self, analysis: RequirementAnalysis) -> GherkinScenario:
|
||||
"""Create a Gherkin scenario from analysis."""
|
||||
steps: List[GherkinStep] = []
|
||||
steps: list[GherkinStep] = []
|
||||
|
||||
if analysis.condition:
|
||||
steps.append(GherkinStep("Given", analysis.condition))
|
||||
@@ -130,7 +134,7 @@ class GherkinGenerator:
|
||||
steps.append(GherkinStep("Then", then_text))
|
||||
|
||||
scenario_type = ScenarioType.SCENARIO
|
||||
examples: List[str] = []
|
||||
examples: list[str] = []
|
||||
|
||||
if analysis.variables:
|
||||
scenario_type = ScenarioType.SCENARIO_OUTLINE
|
||||
@@ -161,7 +165,7 @@ class GherkinGenerator:
|
||||
|
||||
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."""
|
||||
if not analysis.variables:
|
||||
return []
|
||||
@@ -169,7 +173,7 @@ class GherkinGenerator:
|
||||
headers = list(analysis.variables.keys())
|
||||
header_row = "| " + " | ".join(headers) + " |"
|
||||
|
||||
example_rows: List[str] = []
|
||||
example_rows: list[str] = []
|
||||
if analysis.examples:
|
||||
for example in analysis.examples:
|
||||
if isinstance(example, dict):
|
||||
@@ -186,7 +190,7 @@ class GherkinGenerator:
|
||||
|
||||
def _render_feature(self, feature: GherkinFeature) -> str:
|
||||
"""Render a GherkinFeature to string."""
|
||||
lines: List[str] = []
|
||||
lines: list[str] = []
|
||||
|
||||
for tag in feature.tags:
|
||||
lines.append(f"@{tag}")
|
||||
|
||||
Reference in New Issue
Block a user