From 947cc41969efd9093bf3515bf4a02aeb64a9555d Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Mon, 2 Feb 2026 12:45:04 +0000 Subject: [PATCH] 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 --- src/nl2gherkin/exporters/cucumber.py | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/nl2gherkin/exporters/cucumber.py b/src/nl2gherkin/exporters/cucumber.py index bb73cdd..8c16052 100644 --- a/src/nl2gherkin/exporters/cucumber.py +++ b/src/nl2gherkin/exporters/cucumber.py @@ -1,7 +1,5 @@ """Cucumber exporter for JavaScript/TypeScript projects.""" -from typing import Dict, List - from nl2gherkin.exporters.base import BaseExporter @@ -15,12 +13,12 @@ class CucumberExporter(BaseExporter): {{step_definitions}} """ - def export(self, features: List[str]) -> str: + def export(self, features: list[str]) -> str: """Export features to Cucumber format. - + Args: features: List of Gherkin feature strings. - + Returns: Cucumber-compatible feature file content. """ @@ -29,35 +27,35 @@ class CucumberExporter(BaseExporter): def get_step_definitions_template(self) -> str: """Get Cucumber step definitions template. - + Returns: Step definitions template string. """ return self.step_definitions_template - def get_configuration_template(self) -> Dict[str, str]: + def get_configuration_template(self) -> dict[str, str]: """Get Cucumber configuration files. - + Returns: Dictionary mapping filenames to content. """ return { - "cucumber.js": '''module.exports = { + "cucumber.js": """module.exports = { default: '--publish-quiet' } -''', - ".cucumberrc": '''default: +""", + ".cucumberrc": """default: publish-quiet: true format: ['progress-bar', 'html:cucumber-report.html'] -''', +""", } - 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 JavaScript code. """ @@ -70,20 +68,28 @@ class CucumberExporter(BaseExporter): if stripped.startswith(("Given ", "When ", "Then ", "And ")): step_text = " ".join(stripped.split()[1:]) step_def = stripped.split()[0].lower() - indent = " " * (1 if stripped.startswith("And") or stripped.startswith("But") else 0) + " " * (1 if stripped.startswith("And") or stripped.startswith("But") else 0) params = self._extract_parameters(step_text) param_str = ", ".join(f'"{p}"' for p in params) if params else "" params_list = ", ".join(p for p in params) - step_def_code = step_def.capitalize() + "(" + param_str + ", async function (" + params_list + ") {\n" + step_def_code = ( + step_def.capitalize() + + "(" + + param_str + + ", async function (" + + params_list + + ") {\n" + ) step_def_code += " // TODO: implement step\n" step_def_code += "});\n" step_defs.append(step_def_code) 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)