refactor: change from decorator to functional call#129
refactor: change from decorator to functional call#129malto101 wants to merge 1 commit intomozarkai:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the codebase from a decorator-based approach to a functional call approach for self-healing capabilities. The main purpose is to remove the @with_self_healing decorator and replace it with direct method calls to improve code clarity and maintainability.
- Removed the
with_self_healingdecorator and replaced it with a_execute_with_self_healingmethod - Updated method signatures by removing the
locatedparameter and handling element location internally - Improved code formatting and consistency throughout the codebase
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| optics_framework/common/strategies.py | Updated method signatures, improved formatting, fixed return types, and enhanced error handling |
| optics_framework/api/action_keyword.py | Removed decorator pattern, implemented functional approach for self-healing, and updated all action methods |
| rule == "all" and all(found_status.values()) | ||
| ): | ||
| result = True | ||
| timestamp = current_timestamp # Assign timestamp on success |
There was a problem hiding this comment.
The indentation is inconsistent. This line should be aligned with the previous line at the same block level.
| if annotated_frame is not None: | ||
| utils.save_screenshot(annotated_frame, "assert_elements_text_detection_result") |
There was a problem hiding this comment.
The indentation for the screenshot saving logic appears to be outside the finally block scope. This should be properly indented within the finally block.
| if annotated_frame is not None: | |
| utils.save_screenshot(annotated_frame, "assert_elements_text_detection_result") | |
| if annotated_frame is not None: | |
| utils.save_screenshot(annotated_frame, "assert_elements_text_detection_result") |
| def assert_elements(self, elements: list, timeout: int = 30, rule: str = 'any') -> Tuple[bool, str]: | ||
| def assert_elements( | ||
| self, elements: list, timeout: int = 30, rule: str = "any" | ||
| ) -> Tuple[bool, str|None]: |
There was a problem hiding this comment.
Use Union[str, None] or Optional[str] instead of str|None for better compatibility with older Python versions.
| ) -> Tuple[bool, str|None]: | |
| ) -> Tuple[bool, Optional[str]]: |
| def assert_elements(self, elements: list, timeout: int = 30, rule: str = 'any') -> Tuple[bool, str]: | ||
| def assert_elements( | ||
| self, elements: list, timeout: int = 30, rule: str = "any" | ||
| ) -> Tuple[bool, str|None]: |
There was a problem hiding this comment.
Use Union[str, None] or Optional[str] instead of str|None for better compatibility with older Python versions.
| ) -> Tuple[bool, str|None]: | |
| ) -> Tuple[bool, Optional[str]]: |
| utils.save_screenshot(screenshot_np, "enter_number") | ||
| self.driver.enter_text_element(element, str(number), event_name, located=located) | ||
| self._action_screenshot("enter_number") | ||
| self.driver.enter_text_element(element, str(number), event_name) |
There was a problem hiding this comment.
The method call to enter_text_element appears to be missing the located parameter that was previously passed via the decorator. This may cause the method to fail.
| self.driver.enter_text_element(element, str(number), event_name) | |
| located_element = self.element_source.locate(element) | |
| self.driver.enter_text_element(located_element, str(number), event_name) |
84cd473 to
01ecd91
Compare
|



No description provided.