-
Notifications
You must be signed in to change notification settings - Fork 374
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
improve code readability #72
Conversation
clear() | ||
return -1 | ||
# Selection ==================================================== | ||
elif int(com[0]) > 0 and int(com[0]) <= len(choices): | ||
elif com_name.isdigit() and 0 < int(com_name) <= len(choices): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I added condition .isdigit()
, otherwise it could end up with ValueError
when calling int()
on non-numeric string.
@@ -2625,14 +2627,14 @@ def scr_edit_entry_text(self, entry_index, field_index, allow_newlines=True, cle | |||
self.lib.update_entry_field( | |||
entry_index, field_index, new_content.rstrip('\n').rstrip('\r'), 'replace') | |||
|
|||
def scr_list_tags(self, query: str = '', tag_ids: list[int] = [], clear_scr=True) -> None: | |||
def scr_list_tags(self, query: str = '', tag_ids: list[int] = None, clear_scr=True) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the empty list as a default parameter isnt intentional, then it might be causing some issues, see https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments
@@ -4601,7 +4601,7 @@ def expand_collation(self, collation_entries: list[tuple[int, int]]): | |||
for x in collation_entries]) | |||
# self.update_thumbs() | |||
|
|||
def get_frame_contents(self, index=0, query=str): | |||
def get_frame_contents(self, index=0, query: str = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume query=str
was supposed to be query:str
, right? And since it's after a parameter with a default value, it needs some default value as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that looks to be like the original intention. Surprised my linter didn't pick that up...
2eb7507
to
f0f8e0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't believe I didn't know about the get()
method until now...
Overall looks great! Thanks for the cleanup!
Hi,
this PR aims to simplify some pieces of code to improve readability. Beside that there's a few tiny fixes for potential bugs (see my comments on given lines)