Conversation
| if x: | ||
| return True | ||
| return False | ||
| return bool(x := self.vanitas.find_one({"chat_id": chat_id})) |
There was a problem hiding this comment.
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.
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.
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.
Function DB.set_sibyl refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| def is_vanitasalert(user): | ||
| res = get("https://vanitas-api.up.railway.app/user/" + str(user)).json() | ||
| return True if res['blacklisted'] else False | ||
| return bool(res['blacklisted']) |
There was a problem hiding this comment.
Function is_vanitasalert refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity)
| return | ||
| 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.
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.
Function salert refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass)
| return True | ||
| else: | ||
| return False | ||
| return user_data.status in ['administrator', 'creator'] |
There was a problem hiding this comment.
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
inoperator (merge-comparisons)
| return | ||
| 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.
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.
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
mainrefactored 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
mainbranch, then run:Help us improve this pull request!