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