-
Notifications
You must be signed in to change notification settings - Fork 5
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 main branch #1
base: main
Are you sure you want to change the base?
Conversation
x = self.vanitas.find_one({"chat_id": chat_id}) | ||
if x: | ||
return True | ||
return False | ||
return bool(x := self.vanitas.find_one({"chat_id": chat_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 DB.is_vanitas
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Use named expression to simplify assignment and conditional (
use-named-expression
)
set_vanitas = self.is_vanitas(chat_id) | ||
if set_vanitas: | ||
if set_vanitas := self.is_vanitas(chat_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 DB.set_vanitas
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
x = self.sibyl.find_one({"chat_id": chat_id}) | ||
if x: | ||
return True | ||
return False | ||
return bool(x := self.sibyl.find_one({"chat_id": chat_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 DB.is_sibyl
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Use named expression to simplify assignment and conditional (
use-named-expression
)
set_sibyl = self.is_sibyl(chat_id) | ||
if set_sibyl: | ||
if set_sibyl := self.is_sibyl(chat_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 DB.set_sibyl
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
return True if res['blacklisted'] else False | ||
return bool(res['blacklisted']) |
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 is_vanitasalert
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
)
is_sibyl = db.is_sibyl(message.chat.id) | ||
if not is_sibyl: | ||
db.set_sibyl(message.chat.id) | ||
await message.reply_text("Sibyl Alert Enable") | ||
else: | ||
if is_sibyl := db.is_sibyl(message.chat.id): | ||
db.rm_sibyl(message.chat.id) | ||
await message.reply_text("Sibyl Alert Disable") |
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 sibylalert
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches (
swap-if-else-branches
)
else: | ||
pass |
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 salert
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
if user_data.status == 'administrator' or user_data.status == 'creator': | ||
return True | ||
else: | ||
return False | ||
return user_data.status in ['administrator', 'creator'] |
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 is_admin
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Replace if statement with if expression (
assign-if-exp
) - Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
is_vanitas = db.is_vanitas(message.chat.id) | ||
if not is_vanitas: | ||
db.set_vanitas(message.chat.id) | ||
await message.reply_text("Alert Mode Enable") | ||
else: | ||
if is_vanitas := db.is_vanitas(message.chat.id): | ||
db.rm_vanitas(message.chat.id) | ||
await message.reply_text("Alert Mode Disable") |
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 vanitasalert
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap if/else branches (
swap-if-else-branches
)
else: | ||
pass |
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 valert
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.15%.
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
main
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
main
branch, then run:Help us improve this pull request!