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
Conversation
spurge = False | ||
if len(message.command) > 1: | ||
if "-s".lower() in message.command[1].lower(): | ||
spurge = True | ||
spurge = ( | ||
len(message.command) > 1 and "-s".lower() in message.command[1].lower() | ||
) | ||
|
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 purge
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Replace if statement with if expression (
assign-if-exp
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
) - Move setting of default value for variable into
else
branch (introduce-default-else
) - Merge nested if conditions (
merge-nested-ifs
) - Remove redundant pass statement (
remove-redundant-pass
)
text = str(f"{info}\n") | ||
text += "\nUser is a Bot." if user.is_bot else "" | ||
text = str(f"{info}\n") + ("\nUser is a Bot." if user.is_bot else "") |
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 info
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
)
if not len(message.command) > 1: | ||
if len(message.command) <= 1: |
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
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
else: | ||
text = Section( | ||
Link(label="tgEasy", url="https://github.com/jayantkageri/tgEasy"), | ||
"Assistant Robot for tgEasy", | ||
"", | ||
Link( | ||
label="Source Code", | ||
url="https://github.com/DivideProjects/tgEasyAssistant", | ||
), | ||
) | ||
return await message.reply_text(str(text), disable_web_page_preview=True) | ||
text = Section( | ||
Link(label="tgEasy", url="https://github.com/jayantkageri/tgEasy"), | ||
"Assistant Robot for tgEasy", | ||
"", | ||
Link( | ||
label="Source Code", | ||
url="https://github.com/DivideProjects/tgEasyAssistant", | ||
), | ||
) | ||
return await message.reply_text(str(text), disable_web_page_preview=True) |
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 start
refactored with the following changes:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
)
match = re.match(r"captcha\((.+?)\)", cb.data) | ||
if match: | ||
user_id = int(match.group(1)) | ||
if not user_id == cb.from_user.id: | ||
if match := re.match(r"captcha\((.+?)\)", cb.data): | ||
user_id = int(match[1]) | ||
if user_id != cb.from_user.id: |
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 wlc_conf
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups
) - Simplify logical expression using De Morgan identities (
de-morgan
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.57%.
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!