Sourcery refactored Rajkumar branch#163
Conversation
| text = "*{}* has the following settings for the *{}* module:\n\n".format( | ||
| escape_markdown(chat.title), CHAT_SETTINGS[module].__mod_name__ | ||
| ) + CHAT_SETTINGS[module].__chat_settings__(chat_id, user.id) | ||
| text = f"*{escape_markdown(chat.title)}* has the following settings for the *{CHAT_SETTINGS[module].__mod_name__}* module:\n\n" + CHAT_SETTINGS[ | ||
| module | ||
| ].__chat_settings__( | ||
| chat_id, user.id | ||
| ) | ||
|
|
There was a problem hiding this comment.
Function settings_button refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
|
|
||
| if pattern is not None and not pattern.startswith("(?i)"): | ||
| args["pattern"] = "(?i)" + pattern | ||
| args["pattern"] = f"(?i){pattern}" |
There was a problem hiding this comment.
Function register refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
|
|
||
| if pattern is not None and not pattern.startswith("(?i)"): | ||
| args["pattern"] = "(?i)" + pattern | ||
| args["pattern"] = f"(?i){pattern}" |
There was a problem hiding this comment.
Function inlinequery refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| sleep(1) | ||
| with open(f'backups/{datenow}.zip', 'rb') as bkp: | ||
| nm = f"{bot.username} backup \n" + datenow | ||
| nm = f"{bot.username} backup \n{datenow}" |
There was a problem hiding this comment.
Function backup_db refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| text = f"Found **{0}** Demon{1} In This Chat!\n\nWould You Like To Hunt {2} ?".format( | ||
| demons, 's' if demons > 1 else '', | ||
| 'Them All' if demons > 1 else 'That Demon') | ||
| text = f"Found **0** Demon1 In This Chat!\n\nWould You Like To Hunt 2 ?".format( | ||
| demons, | ||
| 's' if demons > 1 else '', | ||
| 'Them All' if demons > 1 else 'That Demon', | ||
| ) | ||
|
|
There was a problem hiding this comment.
Function demons refactored with the following changes:
- Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting)
| if not data or data is None: | ||
| return False | ||
| return data | ||
| return False if not data or data is None else data |
There was a problem hiding this comment.
Function check_media refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp)
| newcity = city.split(",") | ||
| if len(newcity[1]) == 2: | ||
| city = newcity[0].strip() + "," + newcity[1].strip() | ||
| city = f"{newcity[0].strip()},{newcity[1].strip()}" |
There was a problem hiding this comment.
Function weather refactored with the following changes:
- Use f-string instead of string concatenation [×4] (
use-fstring-for-concatenation)
|
|
||
| def button_expired_error(u: Update): | ||
| errmsg = f"This button has expired!" | ||
| errmsg = "This button has expired!" |
There was a problem hiding this comment.
Function button_expired_error refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| if user_id in admin_list: | ||
| return True | ||
| return False | ||
| return user_id in admin_list |
There was a problem hiding this comment.
Function is_user_admin refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast) - Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp)
| if len(res) < 2: | ||
| return user_id, "" | ||
| return user_id, res[1] | ||
| return (user_id, "") if len(res) < 2 else (user_id, res[1]) |
There was a problem hiding this comment.
Function id_from_reply refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp)
ba1c06f to
ed6e2b3
Compare
ed6e2b3 to
74a30ef
Compare
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.13%.
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
Rajkumarrefactored 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
Rajkumarbranch, then run:Help us improve this pull request!