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 947cc41969
commit bc0e737efb

View File

@@ -1,7 +1,5 @@
"""pytest-bdd exporter for pytest projects.""" """pytest-bdd exporter for pytest projects."""
from typing import Dict, List
from nl2gherkin.exporters.base import BaseExporter from nl2gherkin.exporters.base import BaseExporter
@@ -12,7 +10,7 @@ class PytestBDDExporter(BaseExporter):
"""Initialize the pytest-bdd exporter.""" """Initialize the pytest-bdd exporter."""
pass pass
def export(self, features: List[str]) -> str: def export(self, features: list[str]) -> str:
"""Export features to pytest-bdd format. """Export features to pytest-bdd format.
Args: Args:
@@ -57,7 +55,7 @@ def expected_result():
pass pass
''' '''
def get_configuration_template(self) -> Dict[str, str]: def get_configuration_template(self) -> dict[str, str]:
"""Get pytest-bdd configuration files. """Get pytest-bdd configuration files.
Returns: Returns:
@@ -83,12 +81,14 @@ def pytest_configure(config):
"""Configure pytest.""" """Configure pytest."""
pass pass
''', ''',
"pytest.ini": '''[pytest] "pytest.ini": """[pytest]
bdd_features_base_dir = features/ bdd_features_base_dir = features/
''', """,
} }
def generate_step_definitions(self, scenarios: List[str], feature_name: str = "features") -> str: def generate_step_definitions(
self, scenarios: list[str], feature_name: str = "features"
) -> str:
"""Generate step definitions for given scenarios. """Generate step definitions for given scenarios.
Args: Args:
@@ -116,10 +116,10 @@ bdd_features_base_dir = features/
step_def = stripped.split()[0].lower() step_def = stripped.split()[0].lower()
params = self._extract_parameters(step_text) params = self._extract_parameters(step_text)
param_str = ", ".join(f'"{p}"' for p in params) if params else "" ", ".join(f'"{p}"' for p in params) if params else ""
if params: if params:
step_impl = f'''@pytest.{step_def}("{step_text}") step_impl = f'''@{step_def}("{step_text}")
def {step_def}_{scenario_name}({", ".join(params)}): def {step_def}_{scenario_name}({", ".join(params)}):
"""{stripped.split()[0]} step implementation.""" """{stripped.split()[0]} step implementation."""
pass pass
@@ -135,7 +135,8 @@ def {step_def}_{scenario_name}():
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)