-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Conversation
chat: Preference = ( | ||
if chat := ( | ||
session.query(Preference).filter(Preference.user_id == user_id).first() | ||
) | ||
if not chat: | ||
): | ||
chat.language = language | ||
else: | ||
chat = Preference(user_id=user_id, language=language) | ||
session.add(chat) | ||
else: | ||
chat.language = language |
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.
Function update_language
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches (
swap-if-else-branches
)
"Broadcasting completed! Message was sent to {} chats\n".format( | ||
sent_successfully | ||
), | ||
f"Broadcasting completed! Message was sent to {sent_successfully} chats\n", | ||
lang, | ||
) | ||
if failed_to_send: | ||
broadcast_status_message += _( | ||
"Failed to broadcast to {} chats, most likely because bot has been stopped or kicked out.".format( | ||
failed_to_send | ||
), | ||
f"Failed to broadcast to {failed_to_send} chats, most likely because bot has been stopped or kicked out.", |
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.
Function broadcast_handler
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
await event.respond(message, buttons=buttons) if not hasattr( | ||
await event.edit(message, buttons=buttons) if hasattr( | ||
event, "data" | ||
) else await event.edit(message, buttons=buttons) | ||
) else await event.respond(message, buttons=buttons) |
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.
Function preferences_handler
refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression
)
with open(f"restart.pickle", "wb") as out: | ||
with open("restart.pickle", "wb") as out: |
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.
Function restart
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
output_formats_message = "" | ||
for output_format, count in output_formats.items(): | ||
output_formats_message += f" __{output_format}__: {str(count)} times.\n" | ||
input_formats_message = "" | ||
for input_format, count in input_formats.items(): | ||
input_formats_message += f" __{input_format}__: {str(count)} times.\n" | ||
output_formats_message = "".join( | ||
f" __{output_format}__: {str(count)} times.\n" | ||
for output_format, count in output_formats.items() | ||
) | ||
input_formats_message = "".join( | ||
f" __{input_format}__: {str(count)} times.\n" | ||
for input_format, count in input_formats.items() | ||
) |
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.
Function stats
refactored with the following changes:
- Use str.join() instead of for loop [×2] (
use-join
)
with ZipFile(input_file) as book, ZipFile( | ||
f"{input_file}_", "w", compression=ZIP_DEFLATED | ||
) as out: | ||
with (ZipFile(input_file) as book, ZipFile( | ||
f"{input_file}_", "w", compression=ZIP_DEFLATED | ||
) as out): |
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.
Function fix_content_opf_problems
refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups
)
name += " " + event.chat.last_name.strip() | ||
name += f" {event.chat.last_name.strip()}" |
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.
Function get_chat_name
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.41%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!