-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add ISBN 10 to 13 converter bot #335
base: master
Are you sure you want to change the base?
Conversation
# we only update editions with no existing isbn 13s (for now at least) | ||
continue | ||
|
||
isbns_13 = [] |
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.
It is too easy to overlook the plural form when it is in the middle of the variable name.
isbns_13 = [] | |
isbn_13s = [] |
Can't this be a set()
instead of a list()
so the deduping is automatic?
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 avoided that becausi it might randomise the order of the existing entries, but in this specific bot we're only running it on things without existing isbn_13s anyway, so that's probably a worthwhile change.
isbns_13 = dedupe( | ||
isbns_13 | ||
) # remove duplicates, shouldn't normally be necessary |
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.
Do not wrap the line just for a comment.
isbns_13 = dedupe( | |
isbns_13 | |
) # remove duplicates, shouldn't normally be necessary | |
# remove duplicates, shouldn't normally be necessary | |
isbns_13 = dedupe(isbns_13) |
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 we switch to a set, the comment (and code) becomes unnecessary, so that might be the way to go.
self.save(lambda: edition.save(comment=comment)) | ||
|
||
|
||
def dedupe(input_list: list) -> list: |
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.
def dedupe(input_list: list) -> list: | |
def dedupe(input_list: list) -> list: | |
return sorted(set(input_list)) |
Closes #334
Description:
In this Pull Request we have made the following changes: