fix: resolve CI type annotation issues
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

- 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:
2026-02-02 12:45:04 +00:00
parent a93982b27f
commit c1a840454b

View File

@@ -1,7 +1,5 @@
"""Behave exporter for Python BDD projects.""" """Behave exporter for Python BDD projects."""
from typing import Dict, List
from nl2gherkin.exporters.base import BaseExporter from nl2gherkin.exporters.base import BaseExporter
@@ -12,12 +10,12 @@ class BehaveExporter(BaseExporter):
"""Initialize the Behave exporter.""" """Initialize the Behave exporter."""
pass pass
def export(self, features: List[str]) -> str: def export(self, features: list[str]) -> str:
"""Export features to Behave format. """Export features to Behave format.
Args: Args:
features: List of Gherkin feature strings. features: List of Gherkin feature strings.
Returns: Returns:
Behave-compatible feature file content. Behave-compatible feature file content.
""" """
@@ -26,7 +24,7 @@ class BehaveExporter(BaseExporter):
def get_step_definitions_template(self) -> str: def get_step_definitions_template(self) -> str:
"""Get Behave step definitions template. """Get Behave step definitions template.
Returns: Returns:
Step definitions template string. Step definitions template string.
""" """
@@ -53,17 +51,17 @@ def step_then_result(context):
pass pass
''' '''
def get_configuration_template(self) -> Dict[str, str]: def get_configuration_template(self) -> dict[str, str]:
"""Get Behave configuration files. """Get Behave configuration files.
Returns: Returns:
Dictionary mapping filenames to content. Dictionary mapping filenames to content.
""" """
return { return {
"behave.ini": '''[behave] "behave.ini": """[behave]
format = progress format = progress
outfiles = behave-report.txt outfiles = behave-report.txt
''', """,
"features/environment.py": '''"""Behave environment configuration.""" "features/environment.py": '''"""Behave environment configuration."""
def before_scenario(context, scenario): def before_scenario(context, scenario):
@@ -77,12 +75,12 @@ def after_scenario(context, scenario):
''', ''',
} }
def generate_step_definitions(self, scenarios: List[str]) -> str: def generate_step_definitions(self, scenarios: list[str]) -> str:
"""Generate step definitions for given scenarios. """Generate step definitions for given scenarios.
Args: Args:
scenarios: List of scenario texts. scenarios: List of scenario texts.
Returns: Returns:
Step definitions Python code. Step definitions Python code.
""" """
@@ -94,7 +92,7 @@ def after_scenario(context, scenario):
stripped = line.strip() stripped = line.strip()
if stripped.startswith(("Given ", "When ", "Then ", "And ")): if stripped.startswith(("Given ", "When ", "Then ", "And ")):
step_text = " ".join(stripped.split()[1:]) step_text = " ".join(stripped.split()[1:])
step_def = stripped.split()[0].lower() stripped.split()[0].lower()
params = self._extract_parameters(step_text) params = self._extract_parameters(step_text)
@@ -112,7 +110,8 @@ def after_scenario(context, scenario):
return "\n".join(step_defs) return "\n".join(step_defs)
def _extract_parameters(self, step_text: str) -> List[str]: def _extract_parameters(self, step_text: str) -> list[str]:
"""Extract parameters from a step text.""" """Extract parameters from a step text."""
import re import re
return re.findall(r"<([^>]+)>", step_text) return re.findall(r"<([^>]+)>", step_text)