Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mnt/annotate keyboard methods #58

Merged

Conversation

welli7ngton
Copy link
Contributor

@welli7ngton welli7ngton commented Dec 28, 2024

  • MNT: Annotate all keyboard methods
  • style: set double quotes as default quoting, before had no default quoting and
    some methods were using single quotes and some were using double, my formatter (black)
    changed all the quotes to double quotes, and changed the indent of methods (
    find_multiple, find, find_until, find_all, find_text,
    click, click_relative, double_click_relative,
    triple_click_relative, right_click, right_click_relative,
    find_app_element
    )

@welli7ngton
Copy link
Contributor Author

Sorry for the size of the PR, guys, but had some 'automate' changes because of the black formatter and the keyboard session is pretty big ;)

@joao-voltarelli
Copy link
Contributor

@welli7ngton great work!

Just an observation, I noticed that in some keyboard methods, the parameter type or return type was missing:

  • type_key
  • type_keys_with_interval
  • type_keys
  • copy_to_clipboard
  • key_enter
  • Some methods that use alt_<key>
  • Some methods that use control_<key>

Could you please revisit these methods to validate if any adjustments are needed?

@welli7ngton
Copy link
Contributor Author

@joao-voltarelli Alright, asap i'll be solving this!

@welli7ngton
Copy link
Contributor Author

@joao-voltarelli Done! can you give a second check please?

Comment on lines 1138 to 1147
def paste(self, text: Optional[str] = None) -> None:
"""
Paste content from the clipboard.

Args:
text (str, optional): The text to be pasted. Defaults to None
wait (int, optional): Wait interval (ms) after task
"""
if text:
pyperclip.copy(text)
self.control_v()
Copy link
Contributor

Choose a reason for hiding this comment

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

@welli7ngton There was a small problem in our implementation as 'wait' was not being used properly in this method. So, I'm leaving a suggestion for a fix here instead of removing the parameter so that it remains compatible with existing codes. Could you please check?

Suggested change
def paste(self, text: Optional[str] = None) -> None:
"""
Paste content from the clipboard.
Args:
text (str, optional): The text to be pasted. Defaults to None
wait (int, optional): Wait interval (ms) after task
"""
if text:
pyperclip.copy(text)
self.control_v()
def paste(self, text: Optional[str] = None, wait: int = 0) -> None:
"""
Paste content from the clipboard.
Args:
text (str, optional): The text to be pasted. Defaults to None
wait (int, optional): Wait interval (ms) after task
"""
if text:
pyperclip.copy(text)
self.control_v()
delay = max(0, wait or config.DEFAULT_SLEEP_AFTER_ACTION)
self.sleep(delay)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, im working on it! sorry, i haven't thought about this possible incompatibility

"""
Press keys CTRL+C

Args:
wait (int, optional): Wait interval (ms) after task

"""
self.control_key(key_to_press='c', wait=wait)
self.control_key(key_to_press="c", wait=wait)
return self.get_clipboard()

def control_v(self, wait=0):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def control_v(self, wait=0):
def control_v(self, wait: int = 0) -> None:

Comment on lines 1546 to 1551
def control_home(self, wait: int = 0) -> None:
"""
Press keys CTRL+Home
press keys ctrl+home

Args:
wait (int, optional): Wait interval (ms) after task
args:
wait (int, optional): wait interval (ms) after task
Copy link
Contributor

Choose a reason for hiding this comment

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

Adjusting lowercase

Suggested change
def control_home(self, wait: int = 0) -> None:
"""
Press keys CTRL+Home
press keys ctrl+home
Args:
wait (int, optional): Wait interval (ms) after task
args:
wait (int, optional): wait interval (ms) after task
def control_home(self, wait: int = 0) -> None:
"""
Press keys CTRL+Home
Args:
wait (int, optional): Wait interval (ms) after task

@joao-voltarelli
Copy link
Contributor

@welli7ngton Thanks for the adjustments, it looks great!
I just left a few small suggestions in some methods, could you take a look at them later, please?

@joao-voltarelli
Copy link
Contributor

@welli7ngton great work! Thanks for the contribution

@joao-voltarelli joao-voltarelli merged commit d42167e into botcity-dev:main Jan 16, 2025
3 checks passed
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.

2 participants