Apply suggestion to remove unnecessary extra arguments

CURA-12093
This commit is contained in:
Erwan MATHIEU 2024-09-10 12:50:50 +02:00
parent 101a637bbb
commit d74e0487cd
2 changed files with 6 additions and 9 deletions

View File

@ -78,17 +78,12 @@ class GcodeStartEndFormatter:
_instruction_regex = re.compile(r"{(?P<condition>if|else|elif|endif)?\s*(?P<expression>.*?)\s*(?:,\s*(?P<extruder_nr_expr>.*))?\s*}(?P<end_of_line>\n?)")
def __init__(self,
all_extruder_settings: Dict[str, Dict[str, Any]],
default_extruder_nr: int = -1,
cura_application: CuraApplication = None,
extruder_manager: ExtruderManager = None
) -> None:
def __init__(self, all_extruder_settings: Dict[str, Dict[str, Any]], default_extruder_nr: int = -1) -> None:
super().__init__()
self._all_extruder_settings: Dict[str, Dict[str, Any]] = all_extruder_settings
self._default_extruder_nr: int = default_extruder_nr
self._cura_application = cura_application if cura_application is not None else CuraApplication.getInstance()
self._extruder_manager = extruder_manager if extruder_manager is not None else ExtruderManager.getInstance()
self._cura_application = CuraApplication.getInstance()
self._extruder_manager = ExtruderManager.getInstance()
def format(self, text: str) -> str:
remaining_text: str = text

View File

@ -216,5 +216,7 @@ def extruder_manager():
return result
def test_startEndGCode_replace(cura_application, extruder_manager, original_gcode, expected_gcode):
formatter = GcodeStartEndFormatter(all_extruder_settings, -1, cura_application, extruder_manager)
formatter = GcodeStartEndFormatter(all_extruder_settings, -1)
formatter._cura_application = cura_application
formatter._extruder_manager = extruder_manager
assert formatter.format(original_gcode) == expected_gcode