Skip to content

refactor: change from decorator to functional call#129

Open
malto101 wants to merge 1 commit intomozarkai:mainfrom
malto101:fix-lib
Open

refactor: change from decorator to functional call#129
malto101 wants to merge 1 commit intomozarkai:mainfrom
malto101:fix-lib

Conversation

@malto101
Copy link
Member

No description provided.

@malto101 malto101 requested review from Copilot and davidamo9 July 16, 2025 04:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_healing decorator and replaced it with a _execute_with_self_healing method
  • Updated method signatures by removing the located parameter 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
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent. This line should be aligned with the previous line at the same block level.

Copilot uses AI. Check for mistakes.
Comment on lines 178 to 179
if annotated_frame is not None:
utils.save_screenshot(annotated_frame, "assert_elements_text_detection_result")
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation for the screenshot saving logic appears to be outside the finally block scope. This should be properly indented within the finally block.

Suggested change
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")

Copilot uses AI. Check for mistakes.
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]:
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Union[str, None] or Optional[str] instead of str|None for better compatibility with older Python versions.

Suggested change
) -> Tuple[bool, str|None]:
) -> Tuple[bool, Optional[str]]:

Copilot uses AI. Check for mistakes.
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]:
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Union[str, None] or Optional[str] instead of str|None for better compatibility with older Python versions.

Suggested change
) -> Tuple[bool, str|None]:
) -> Tuple[bool, Optional[str]]:

Copilot uses AI. Check for mistakes.
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)
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
@malto101 malto101 force-pushed the fix-lib branch 4 times, most recently from 84cd473 to 01ecd91 Compare July 16, 2025 06:37
@davidamo9 davidamo9 marked this pull request as draft July 17, 2025 05:52
@malto101 malto101 marked this pull request as ready for review July 17, 2025 10:20
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants