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:
@@ -1,7 +1,5 @@
|
|||||||
"""Cucumber exporter for JavaScript/TypeScript projects."""
|
"""Cucumber exporter for JavaScript/TypeScript projects."""
|
||||||
|
|
||||||
from typing import Dict, List
|
|
||||||
|
|
||||||
from nl2gherkin.exporters.base import BaseExporter
|
from nl2gherkin.exporters.base import BaseExporter
|
||||||
|
|
||||||
|
|
||||||
@@ -15,12 +13,12 @@ class CucumberExporter(BaseExporter):
|
|||||||
{{step_definitions}}
|
{{step_definitions}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def export(self, features: List[str]) -> str:
|
def export(self, features: list[str]) -> str:
|
||||||
"""Export features to Cucumber format.
|
"""Export features to Cucumber format.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
features: List of Gherkin feature strings.
|
features: List of Gherkin feature strings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Cucumber-compatible feature file content.
|
Cucumber-compatible feature file content.
|
||||||
"""
|
"""
|
||||||
@@ -29,35 +27,35 @@ class CucumberExporter(BaseExporter):
|
|||||||
|
|
||||||
def get_step_definitions_template(self) -> str:
|
def get_step_definitions_template(self) -> str:
|
||||||
"""Get Cucumber step definitions template.
|
"""Get Cucumber step definitions template.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Step definitions template string.
|
Step definitions template string.
|
||||||
"""
|
"""
|
||||||
return self.step_definitions_template
|
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.
|
"""Get Cucumber configuration files.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dictionary mapping filenames to content.
|
Dictionary mapping filenames to content.
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"cucumber.js": '''module.exports = {
|
"cucumber.js": """module.exports = {
|
||||||
default: '--publish-quiet'
|
default: '--publish-quiet'
|
||||||
}
|
}
|
||||||
''',
|
""",
|
||||||
".cucumberrc": '''default:
|
".cucumberrc": """default:
|
||||||
publish-quiet: true
|
publish-quiet: true
|
||||||
format: ['progress-bar', 'html:cucumber-report.html']
|
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.
|
"""Generate step definitions for given scenarios.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
scenarios: List of scenario texts.
|
scenarios: List of scenario texts.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Step definitions JavaScript code.
|
Step definitions JavaScript code.
|
||||||
"""
|
"""
|
||||||
@@ -70,20 +68,28 @@ class CucumberExporter(BaseExporter):
|
|||||||
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()
|
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)
|
params = self._extract_parameters(step_text)
|
||||||
param_str = ", ".join(f'"{p}"' for p in params) if params else ""
|
param_str = ", ".join(f'"{p}"' for p in params) if params else ""
|
||||||
params_list = ", ".join(p for p in params)
|
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 += " // TODO: implement step\n"
|
||||||
step_def_code += "});\n"
|
step_def_code += "});\n"
|
||||||
step_defs.append(step_def_code)
|
step_defs.append(step_def_code)
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user