-
-
Notifications
You must be signed in to change notification settings - Fork 3
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 DOGE branch #4
base: DOGE
Are you sure you want to change the base?
Conversation
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.
Due to GitHub API limits, only the first 60 comments can be shown.
userbot/helpers/functions/utube.py
Outdated
Button.inline(f"🌟 Bᴇsᴛ - 🎞 ᴍᴋᴠ", data=f"ytdl_download_{vid}_mkv_v"), | ||
Button.inline('🌟 Bᴇsᴛ - 🎞 ᴍᴋᴠ', data=f"ytdl_download_{vid}_mkv_v"), | ||
Button.inline( | ||
f"🌟 Bᴇsᴛ - 🎞 ᴡᴇʙᴍ/ᴍᴘ4", | ||
data=f"ytdl_download_{vid}_mp4_v", | ||
'🌟 Bᴇsᴛ - 🎞 ᴡᴇʙᴍ/ᴍᴘ4', data=f"ytdl_download_{vid}_mp4_v" | ||
), | ||
] | ||
] | ||
|
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 download_button
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
f"**🚨 Eʀʀoʀ:** The uploader hasn't made this video available in your country." | ||
"**🚨 Eʀʀoʀ:** The uploader hasn't made this video available in your country." | ||
) | ||
|
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 _tubeDl
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/helpers/utils/events.py
Outdated
return f"\n\n<b>🧡 This user is my developer!</b>" | ||
return '\n\n<b>🧡 This user is my developer!</b>' |
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 wowcmydev
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/helpers/utils/events.py
Outdated
return f"\n\n<b>🤡 This user has been banned from using Doge.</b>" | ||
return '\n\n<b>🤡 This user has been banned from using Doge.</b>' |
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 wowcg_y
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/helpers/utils/events.py
Outdated
await edl(dogevent, f"**🚨 Eʀʀoʀ:**\n`ℹ️ Couldn't fetch the chat!`") | ||
await edl(dogevent, "**🚨 Eʀʀoʀ:**\n`ℹ️ Couldn't fetch the chat!`") |
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_chatinfo
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/helpers/utils/format.py
Outdated
return f"**🚨 Eʀʀoʀ:** While pasting text to site" | ||
return '**🚨 Eʀʀoʀ:** While pasting text to site' |
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 paste_message
refactored with the following changes:
- Split conditional into multiple branches (
split-or-ifs
) - Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Remove redundant conditional (
remove-redundant-if
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
c = title if title else "🐶 Doge UserBot 🐾" | ||
c = title or "🐶 Doge UserBot 🐾" |
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 t_paste
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
userbot/helpers/utils/paste.py
Outdated
er = "pasty.lus.pm" | ||
return {"error": f"`🚨 Unable to reach {er}!`"} | ||
return {"error": f'`🚨 Unable to reach pasty.lus.pm!`'} |
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 p_paste
refactored with the following changes:
- Inline variable that is only used once (
inline-variable
) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting
)
userbot/helpers/utils/paste.py
Outdated
er = "spacebin" | ||
return {"error": f"`🚨 Unable to reach {er}!`"} | ||
return {"error": f'`🚨 Unable to reach spacebin!`'} |
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 s_paste
refactored with the following changes:
- Inline variable that is only used once (
inline-variable
) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting
)
userbot/helpers/utils/paste.py
Outdated
er = "nekobin" | ||
return {"error": f"`🚨 Unable to reach {er}!`"} | ||
return {"error": f'`🚨 Unable to reach nekobin!`'} |
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 n_paste
refactored with the following changes:
- Inline variable that is only used once (
inline-variable
) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting
)
userbot/helpers/utils/paste.py
Outdated
er = "catbin" | ||
return {"error": f"`🚨 Unable to reach {er}!`"} | ||
return {"error": f'`🚨 Unable to reach catbin!`'} |
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 d_paste
refactored with the following changes:
- Inline variable that is only used once (
inline-variable
) - Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting
)
elif media_t != "Sticker" and media_t: | ||
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 afksetter
refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if
)
userbot/plugins/afk.py
Outdated
last = user.last_name if user.last_name else "" | ||
last = user.last_name or "" | ||
fullname = f"{first} {last}" if last else first | ||
username = f"@{user.username}" if user.username else mention | ||
me = await event.client.get_me() | ||
my_mention = f"[{me.first_name}](tg://user?id={me.id})" | ||
my_first = me.first_name | ||
my_last = me.last_name if me.last_name else "" | ||
my_last = me.last_name or "" |
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 on_afk
refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Remove redundant conditional (
remove-redundant-if
) - Replace if statement with if expression (
assign-if-exp
) - Simplify if expression by using or (
or-if-exp-identity
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
userbot/plugins/corecmds copy.py
Outdated
if event.reply_to_msg_id: | ||
reply_message = await event.get_reply_message() | ||
try: | ||
downloaded_file_name = await event.client.download_media( | ||
reply_message, | ||
"userbot/plugins/", | ||
) | ||
if "(" not in downloaded_file_name: | ||
path1 = Path(downloaded_file_name) | ||
shortname = path1.stem | ||
shortestname = shortname.replace(".py", "") | ||
try: | ||
load_module(shortestname) | ||
except ModuleNotFoundError as mnfe: | ||
remove(downloaded_file_name) | ||
return await edl( | ||
event, | ||
f"**🚨 Eʀʀoʀ:**\ | ||
if not event.reply_to_msg_id: | ||
return | ||
reply_message = await event.get_reply_message() | ||
try: | ||
downloaded_file_name = await event.client.download_media( | ||
reply_message, | ||
"userbot/plugins/", | ||
) | ||
if "(" not in downloaded_file_name: | ||
path1 = Path(downloaded_file_name) | ||
shortname = path1.stem | ||
shortestname = shortname.replace(".py", "") | ||
try: | ||
load_module(shortestname) | ||
except ModuleNotFoundError as mnfe: | ||
remove(downloaded_file_name) | ||
return await edl( | ||
event, | ||
f"**🚨 Eʀʀoʀ:**\ | ||
\n➡️ `{mnfe}`\ | ||
\n\ | ||
\n**🦴 Try to write** `{tr}finstall` **& reply.**", | ||
15, | ||
) | ||
15, | ||
) | ||
|
||
try: | ||
await reply_message.forward_to(PLUGIN_CHANNEL) | ||
except Exception: | ||
remove(downloaded_file_name) | ||
return await edl( | ||
event, | ||
f"**🚨 Eʀʀoʀ:**\ | ||
try: | ||
await reply_message.forward_to(PLUGIN_CHANNEL) | ||
except Exception: | ||
remove(downloaded_file_name) | ||
return await edl( | ||
event, | ||
f"**🚨 Eʀʀoʀ:**\ |
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 install
refactored with the following changes:
- Add guard clause (
last-if-guard
)
userbot/plugins/corecmds copy.py
Outdated
if event.reply_to_msg_id: | ||
reply_message = await event.get_reply_message() | ||
try: | ||
downloaded_file_name = await event.client.download_media( | ||
reply_message, | ||
"userbot/plugins/", | ||
) | ||
if "(" not in downloaded_file_name: | ||
path1 = Path(downloaded_file_name) | ||
shortname = path1.stem | ||
shortestname = shortname.replace(".py", "") | ||
try: | ||
load_module(shortestname) | ||
except ModuleNotFoundError as e: | ||
install_pip(e.name) | ||
sleep(1) | ||
load_module(shortestname) | ||
if not event.reply_to_msg_id: | ||
return | ||
reply_message = await event.get_reply_message() | ||
try: | ||
downloaded_file_name = await event.client.download_media( | ||
reply_message, | ||
"userbot/plugins/", | ||
) | ||
if "(" not in downloaded_file_name: | ||
path1 = Path(downloaded_file_name) | ||
shortname = path1.stem | ||
shortestname = shortname.replace(".py", "") | ||
try: | ||
load_module(shortestname) | ||
except ModuleNotFoundError as e: | ||
install_pip(e.name) | ||
sleep(1) | ||
load_module(shortestname) | ||
|
||
try: | ||
await reply_message.forward_to(PLUGIN_CHANNEL) | ||
except Exception: | ||
remove(downloaded_file_name) | ||
return await edl( | ||
event, | ||
f"**🚨 Eʀʀoʀ:**\ | ||
try: | ||
await reply_message.forward_to(PLUGIN_CHANNEL) | ||
except Exception: | ||
remove(downloaded_file_name) | ||
return await edl( | ||
event, | ||
f"**🚨 Eʀʀoʀ:**\ |
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 finstall
refactored with the following changes:
- Add guard clause (
last-if-guard
)
userbot/plugins/help copy.py
Outdated
outstr += f"**🔹 Iɴғo:** -\n\n" | ||
outstr += '**🔹 Iɴғo:** -\n\n' |
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 plugininfo
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/plugins/images.py
Outdated
return await edl(dogevent, f"**Error:**\n__Invalid dimension.__") | ||
return await edl(dogevent, '**Error:**\n__Invalid dimension.__') | ||
else: | ||
try: | ||
nw = int(args[0]) | ||
except ValueError: | ||
return await edl(dogevent, f"**Error:**\n__Invalid width.__") | ||
return await edl(dogevent, '**Error:**\n__Invalid width.__') | ||
try: | ||
nh = int(args[1]) | ||
except ValueError: | ||
return await edl(dogevent, f"**Error:**\n__Invalid height.__") | ||
return await edl(dogevent, '**Error:**\n__Invalid height.__') |
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 iresize
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/plugins/images.py
Outdated
await edl(output[0], f"**Error**\n`{str(e)}`") | ||
await edl(output[0], f'**Error**\n`{e}`') |
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 txt_art
refactored with the following changes:
- Simplify unnecessary nesting, casting and constant values in f-strings (
simplify-fstring-formatting
)
userbot/plugins/info.py
Outdated
caption += m_st_r if m_st_r else "" | ||
caption += g_y if g_y else "" | ||
caption += m_st_r or "" | ||
caption += g_y or "" |
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 fetch_info
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
userbot/plugins/logo.py
Outdated
or f"https://raw.githubusercontent.com/DOG-E/Source/DOGE/Material/LogoBackgrounds/black.jpg" | ||
or 'https://raw.githubusercontent.com/DOG-E/Source/DOGE/Material/LogoBackgrounds/black.jpg' | ||
) | ||
|
||
LOGO_FONT = ( | ||
gvar("LOGO_FONT") | ||
or f"https://github.com/DOG-E/Source/raw/DOGE/Material/Fonts/streamster.ttf" | ||
or 'https://github.com/DOG-E/Source/raw/DOGE/Material/Fonts/streamster.ttf' | ||
) | ||
|
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 very
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
ad5e2f2
to
fdb7faf
Compare
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.
Sourcery timed out performing refactorings.
Due to GitHub API limits, only the first 60 comments can be shown.
sample_config.py
Outdated
|
||
|
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.
Lines 67-67
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
if not self.jsobj: | ||
return None | ||
return self.jsobj | ||
return None if not self.jsobj else self.jsobj |
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 Main.parse_storage.TheHTMLParser.result
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
)
opt_file = self.options.file | ||
if opt_file: | ||
if opt_file := self.options.file: |
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 Main.create_file_name
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
__copyright__ = "©️ Copyright 2021, " + __author__ | ||
__copyright__ = f"©️ Copyright 2021, {__author__}" |
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.
Lines 21-62
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
LOGS.info(f"⏳ STARTING DOGE USERBOT 🐾") | ||
LOGS.info("⏳ STARTING DOGE USERBOT 🐾") | ||
doge.loop.run_until_complete(setup_bot()) | ||
LOGS.info(f"✅ STARTUP COMPLETED 🐾") | ||
LOGS.info("✅ STARTUP COMPLETED 🐾") |
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.
Lines 33-35
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
doginput = "Inline buttons " + markdown_note | ||
doginput = f"Inline buttons {markdown_note}" |
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 button
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok." | ||
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok." | ||
else: | ||
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok." | ||
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok." |
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 on_plug_in_callback_query_handler
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
event, f"**📺 Geçerli bir YouTube URL'sine girin veya cevap verin!**" | ||
event, "**📺 Geçerli bir YouTube URL'sine girin veya cevap verin!**" | ||
) | ||
|
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 yt_inline
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
await c_q.answer(f"➡️ Görünüm olarak şu değiştirildi: 📜 Liste", alert=False) | ||
await c_q.answer("➡️ Görünüm olarak şu değiştirildi: 📜 Liste", alert=False) |
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 ytdl_callback
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok." | ||
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok." | ||
else: | ||
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok." | ||
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok." |
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 on_plug_in_callback_query_handler
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
if reply_message.media: | ||
media = await reply_message.download_media() | ||
if reply_message.text: | ||
await doge.tgbot.send_file(chat, media, caption=reply_message.text) | ||
else: | ||
await doge.tgbot.send_file(chat, media) | ||
return await event.delete() | ||
|
||
else: | ||
if not reply_message.media: | ||
return await edl( | ||
event, | ||
"__Bot üzerinden ne göndermeliyim? Bana bir metin verin ya da mesajı yanıtlayın.__", | ||
) | ||
|
||
media = await reply_message.download_media() | ||
if reply_message.text: | ||
await doge.tgbot.send_file(chat, media, caption=reply_message.text) | ||
else: | ||
await doge.tgbot.send_file(chat, media) | ||
return await event.delete() | ||
|
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 botmsg
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok." | ||
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok." | ||
else: | ||
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok." | ||
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok." |
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 on_plug_in_callback_query_handler
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
text = "**🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" | ||
text += "\n\n" | ||
text = "**🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" + "\n\n" | ||
text += f"**🚨 Hata Raporu:** [{new['error']}]({pastelink})" | ||
text += "\n\n" | ||
link = f"[BURAYA](https://t.me/DogeSup)" | ||
link = "[BURAYA](https://t.me/DogeSup)" |
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 DogeUserBotClient.bot_cmd.decorator.wrapper
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
text = "**🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" | ||
text += "\n\n" | ||
text = "**🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" + "\n\n" | ||
text += f"**🚨 Hata Raporu:** [{new['error']}]({pastelink})" | ||
text += "\n\n" | ||
link = f"[BURAYA](https://t.me/DogeSup)" | ||
link = "[BURAYA](https://t.me/DogeSup)" |
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 DogeUserBotClient.shiba_cmd.decorator.wrapper
refactored with the following changes:
- Replace assignment and augmented assignment with single assignment (
merge-assign-and-aug-assign
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
tmp_chelp += f"\n\n**🐾 Aʏᴀʀ:**" | ||
tmp_chelp += "\\n\\n**🐾 Aʏᴀʀ:**" |
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 _format_about
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
exact_size = ( | ||
",isz:ex,iszw:" + str(size_array[0]) + ",iszh:" + str(size_array[1]) | ||
) | ||
exact_size = f",isz:ex,iszw:{str(size_array[0])},iszh:{str(size_array[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 googleimagesdownload.build_url_parameters
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace calls to
dict.items
withdict.values
when the keys are not used. (replace-dict-items-with-values
)
for line in f: | ||
if line not in ["\n", "\r\n"]: | ||
search_keyword.append(line.replace("\n", "").replace("\r", "")) | ||
search_keyword.extend( | ||
line.replace("\n", "").replace("\r", "") | ||
for line in f | ||
if line not in ["\n", "\r\n"] | ||
) | ||
|
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 googleimagesdownload.keywords_from_file
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
)
dir_name_thumbnail = dir_name + " - thumbnail" | ||
dir_name_thumbnail = f'{dir_name} - thumbnail' |
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 googleimagesdownload.create_directories
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
print("Image URL: " + image_url) | ||
print(f"Image URL: {image_url}") |
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 googleimagesdownload.download_image_thumbnail
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace if statement with if expression (
assign-if-exp
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
arguments = {} | ||
for i in args_list: | ||
arguments[i] = None | ||
arguments = {i: None for i in args_list} |
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 googleimagesdownload.download
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
)
username = replied_user.user.username | ||
if username: | ||
if username := replied_user.user.username: |
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 slap
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
horny = f"**Kategori:** " | ||
horny = "**Kategori:** " |
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 nsfw
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
userbot/helpers/progress.py
Outdated
return str(round(size, 2)) + " " + dict_power_n[raised_to_pow] + "B" | ||
return f'{str(round(size, 2))} {dict_power_n[raised_to_pow]}B' |
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 humanbytes
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
((str(days) + f" gün, ") if days else "") | ||
+ ((str(hours) + f" saat, ") if hours else "") | ||
+ ((str(minutes) + f" dakika, ") if minutes else "") | ||
+ ((str(seconds) + f" saniye, ") if seconds else "") | ||
(f"{str(days)} gün, " if days else "") | ||
+ (f"{str(hours)} saat, " if hours else "") | ||
+ (f"{str(minutes)} dakika, " if minutes else "") | ||
+ (f"{str(seconds)} saniye, " if seconds 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 time_formatter
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
userbot/helpers/progress.py
Outdated
((str(int(days)) + f" gün, ") if days else "") | ||
+ ((str(int(hours)) + ":") if hours else "00:") | ||
+ ((str(int(minutes)) + ":") if minutes else "00:") | ||
(f"{int(days)} gün, " if days else "") | ||
+ (f'{int(hours)}:' if hours else "00:") | ||
+ (f'{int(minutes)}:' if minutes else "00:") |
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 readable_time
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Remove unnecessary calls to
str()
from formatted values in f-strings (remove-str-from-fstring
)
outlineRange = int(fontSize / 15) | ||
outlineRange = fontSize // 15 |
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 dogememify_helper
refactored with the following changes:
- Simplify division expressions. (
simplify-division
)
userbot/helpers/functions/jikan.py
Outdated
msg += f"\n**Genres:** " | ||
msg += "\\n**Genres:** " | ||
for g in jsonData["genres"]: | ||
msg += g + " " | ||
msg += f'{g} ' |
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 formatJSON
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
description = description[0:200] + "....." | ||
description = description[:200] + "....." |
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 shorten
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
error = result.get("errors") | ||
if error: | ||
if error := result.get("errors"): |
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 anilist_user
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
userbot/helpers/functions/jikan.py
Outdated
image = post("https://graphql.anilist.co", json=data).json()["data"]["Media"][ | ||
"bannerImage" | ||
] | ||
if image: | ||
if image := post("https://graphql.anilist.co", json=data).json()["data"][ | ||
"Media" | ||
]["bannerImage"]: |
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 getBannerLink
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
Signed-off-by: TeleDoge <DogeUserBot@gmail.com>
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.17%.
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! |
Sourcery Code Quality Report✅ Merging this PR will increase 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
DOGE
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
DOGE
branch, then run:Help us improve this pull request!