Skip to content

Conversation

@welli7ngton
Copy link
Contributor

  • Enhanced type annotations across botcity/core/bot.py and botcity/core/cv2find.py for better type safety and developer experience.
  • Added type hints to parameters and return types in key methods like find, find_all, find_until, and _load_cv2.
  • Ensured proper usage of Optional, List, Tuple, and Generator in function definitions.
  • Standardized method signatures for consistency, explicitly defining default values and expected data types.
  • Updated imports to include necessary types like Union, Optional, List, Tuple, Dict, and Generator.

>> - Enhanced type annotations across botcity/core/bot.py and botcity/core/cv2find.py for better type safety and developer experience.
>> - Added type hints to parameters and return types in key methods like find, find_all, find_until, and _load_cv2.
>> - Ensured proper usage of Optional, List, Tuple, and Generator in function definitions.
>> - Standardized method signatures for consistency, explicitly defining default values and expected data types.
>> - Updated imports to include necessary types like Union, Optional, List, Tuple, Dict, and Generator.
@welli7ngton
Copy link
Contributor Author

I'll solve asap, Box is not implemented in python 3.9
ImportError: cannot import name 'Box' from 'typing' (/opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/typing.py)

@welli7ngton
Copy link
Contributor Author

@joao-voltarelli @hhslepicka

I’ve attempted to add type annotations to the cv2find module, but I’m not entirely confident that the typings are correct. While working on it in LunarVim, I encountered numerous linter errors, primarily due to conflicts between Black and Flake8. However, when I tested the same in VSCode, everything appeared fine, with no issues reported.

Could you please review the typings and confirm if they align with what’s expected?

Comment on lines 513 to 525
def find_text(
self,
label,
x=None,
y=None,
width=None,
height=None,
label: str,
x: Optional[int] = None,
y: Optional[int] = None,
width: Optional[int] = None,
height: Optional[int] = None,
*,
threshold=None,
matching=0.9,
waiting_time=10000,
best=True,
threshold: Optional[int] = None,
matching: float = 0.9,
waiting_time: int = 10000,
best: bool = True,
):
Copy link
Contributor

Choose a reason for hiding this comment

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

Return type is missing

@joao-voltarelli
Copy link
Contributor

@welli7ngton great work with the computer vision methods!

Just a small suggestion, I think that in methods like find, find_until, find_text, and get_last_element, it might be interesting if the return type were cv2find.Box, which is a named tuple, instead of Tuple[int, int, int, int].

This way, we can keep the code more readable, and if there is any future update to the structure of the "Box" named tuple, we will not need to change it in each method.

@joao-voltarelli
Copy link
Contributor

Overall, I ran some tests using the computer vision methods, and everything seemed to work fine!

Just as a reference, I printed the element and the return type in the code for each method I tested, and these were the results:
framework-core-return-types.txt

Feel free to use it as a reference or even do more tests if you want.

@welli7ngton
Copy link
Contributor Author

@joao-voltarelli fixed! thanks for the attention

@welli7ngton
Copy link
Contributor Author

@welli7ngton great work with the computer vision methods!

Just a small suggestion, I think that in methods like find, find_until, find_text, and get_last_element, it might be interesting if the return type were cv2find.Box, which is a named tuple, instead of Tuple[int, int, int, int].

This way, we can keep the code more readable, and if there is any future update to the structure of the "Box" named tuple, we will not need to change it in each method.

I'll work on it, thanks for the suggestion!

…d get_last_element to cv2find.Box to improve code readability
@joao-voltarelli
Copy link
Contributor

@welli7ngton Thanks for the contribution!

@joao-voltarelli joao-voltarelli merged commit c19614f into botcity-dev:main Jan 27, 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