-
-
Notifications
You must be signed in to change notification settings - Fork 26
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 Starbot ⭐ refactored PredaaA/predacogs #58
base: master
Are you sure you want to change the base?
Conversation
if not member.guild.id == config["support_server_role"]["guild_id"]: | ||
if member.guild.id != config["support_server_role"]["guild_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 DblTools.on_member_join
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
votes.append((user if user else user_id, humanize_number(value))) | ||
votes.append((user or user_id, humanize_number(value))) |
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 DblTools.listdblvotes
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
return True if datetime.today().weekday() in [4, 5, 6] else False | ||
return datetime.today().weekday() in [4, 5, 6] |
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 check_weekend
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
)
votes.append((user if user else user_id, humanize_number(value))) | ||
votes.append((user or user_id, humanize_number(value))) |
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 DblToolsLite.listdblvotes
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
if ctx.channel.permissions_for(ctx.me).embed_links: | ||
em = discord.Embed( | ||
color=await ctx.embed_colour(), title=f"FiveM settings for {self.bot.user}" | ||
) | ||
msg = "" | ||
for attr, name in settings_name.items(): | ||
if attr == "toggled": | ||
if settings[attr]: | ||
msg += f"**{name}** Yes\n" | ||
else: | ||
msg += f"**{name}** No\n" | ||
elif attr == "ip": | ||
if settings[attr]: | ||
msg += f"**{name}** {inline(settings[attr])}\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "text": | ||
if settings[attr]: | ||
msg += f"**{name}**\n{inline(settings[attr])}\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "streamer": | ||
if settings[attr]: | ||
msg += f"**{name}** {inline(settings[attr])}\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "stream_title": | ||
if settings[attr]: | ||
msg += f"**{name}** {inline(settings[attr])}\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
else: | ||
msg = "" | ||
for attr, name in settings_name.items(): | ||
if attr in ["ip", "streamer", "stream_title"]: | ||
if settings[attr]: | ||
msg += f"**{name}** {inline(settings[attr])}\n" | ||
em.description = msg | ||
await ctx.send(embed=em) | ||
else: | ||
msg = "```\n" | ||
for attr, name in settings_name.items(): | ||
if attr == "toggled": | ||
if settings[attr]: | ||
msg += f"{name} Yes\n" | ||
else: | ||
msg += f"{name} No\n" | ||
elif attr == "ip": | ||
if settings[attr]: | ||
msg += f"{name} {settings[attr]}\n" | ||
else: | ||
msg += f"{name} Not set\n" | ||
elif attr == "text": | ||
if settings[attr]: | ||
msg += f"{name}\n{settings[attr]}\n" | ||
else: | ||
msg += f"{name} Not set\n" | ||
elif attr == "streamer": | ||
if settings[attr]: | ||
msg += f"{name} {settings[attr]}\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "stream_title": | ||
if settings[attr]: | ||
msg += f"{name} {settings[attr]}\n" | ||
else: | ||
msg += f"{name} Not set\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "text": | ||
if settings[attr]: | ||
msg += f"**{name}**\n{inline(settings[attr])}\n" | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "toggled": | ||
msg += f"**{name}** Yes\n" if settings[attr] else f"**{name}** No\n" | ||
else: | ||
msg += f"**{name}** {inline(settings[attr])}\n" | ||
em.description = msg | ||
await ctx.send(embed=em) | ||
else: | ||
msg = "```\n" | ||
for attr, name in settings_name.items(): | ||
if attr in ["ip", "stream_title"]: | ||
msg += f"{name} {settings[attr]}\n" if settings[attr] else f"{name} Not set\n" | ||
elif attr == "streamer": | ||
if settings[attr]: | ||
msg += f"{name} {settings[attr]}\n" | ||
msg += "```" | ||
await ctx.send(msg) | ||
else: | ||
msg += f"**{name}** Not set\n" | ||
elif attr == "text": | ||
msg += f"{name}\n{settings[attr]}\n" if settings[attr] else f"{name} Not set\n" | ||
elif attr == "toggled": | ||
msg += f"{name} Yes\n" if settings[attr] else f"{name} No\n" | ||
else: | ||
msg += f"{name} {settings[attr]}\n" | ||
msg += "```" | ||
await ctx.send(msg) |
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 FiveM.fivemset
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Add guard clause (
last-if-guard
) - Replace if statement with if expression (
assign-if-exp
)
description = ( | ||
return ( |
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 Core._about_cog._launchpads_texts
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
description = ( | ||
return ( | ||
"Status: **{status}**\n" | ||
"Landing type: **{landing_t}**\n" | ||
"Attempted landings: **{att_lands}**\n" | ||
"Success landings: **{succ_lands}**\n" | ||
"Location: **{location}**" | ||
).format(**description_kwargs) | ||
return description |
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 Core._about_cog._landpads_texts
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
description = ( | ||
return ( | ||
data["description"] | ||
+ "\n**[Wikipedia page]({})**".format(data["wikipedia"]) | ||
+ "{website}{twitter}" | ||
).format(**description_kwargs) | ||
return description |
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 Core._about_cog._missions_texts
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
roadster_stats = ( | ||
return ( | ||
"Launch date: **{launch_date} {ago} ago**\n" | ||
"Launch mass: **{mass_kg:,} kg / {mass_lbs:,} lbs**\n" | ||
"Actual speed: **{speed_km:,} km/h / {speed_mph:,} mph**\n" | ||
"Earth distance: **{e_distance_km:,} km / {e_distance_mi:,} mi**\n" | ||
"Mars distance: **{m_distance_km:,} km / {m_distance_mi:,} mi**\n" | ||
).format(**roadster_stats_kwargs) | ||
return roadster_stats |
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 Core._about_cog._roadster_texts
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
payload_weights_stats = "" | ||
for p in data["payload_weights"]: | ||
payload_weights_stats += ( | ||
"Name: **{p_name}**\n" "Weight: **{kg_mass:,} kg / {lb_mass:,} lbs**\n" | ||
payload_weights_stats = "".join( | ||
( | ||
"Name: **{p_name}**\n" | ||
"Weight: **{kg_mass:,} kg / {lb_mass:,} lbs**\n" | ||
).format(p_name=p["name"], kg_mass=p["kg"], lb_mass=p["lb"]) | ||
for p in data["payload_weights"] | ||
) | ||
|
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 Core._about_cog._rockets_texts
refactored with the following changes:
- Use str.join() instead of for loop (
use-join
)
I dont entirely suggest using sourcery since it will push breaking changes with little to no testing. |
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: