Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SourceryAI
Copy link

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:

git fetch https://github.com/sourcery-ai-bot/predacogs master
git merge --ff-only FETCH_HEAD
git reset HEAD^

if not member.guild.id == config["support_server_role"]["guild_id"]:
if member.guild.id != config["support_server_role"]["guild_id"]:
Copy link
Author

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)))
Copy link
Author

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:

return True if datetime.today().weekday() in [4, 5, 6] else False
return datetime.today().weekday() in [4, 5, 6]
Copy link
Author

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:

votes.append((user if user else user_id, humanize_number(value)))
votes.append((user or user_id, humanize_number(value)))
Copy link
Author

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:

Comment on lines -156 to +209
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)
Copy link
Author

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:

Comment on lines -186 to +187
description = (
return (
Copy link
Author

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:

Comment on lines -212 to -219
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
Copy link
Author

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:

Comment on lines -231 to -236
description = (
return (
data["description"]
+ "\n**[Wikipedia page]({})**".format(data["wikipedia"])
+ "{website}{twitter}"
).format(**description_kwargs)
return description
Copy link
Author

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:

Comment on lines -252 to -259
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
Copy link
Author

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:

Comment on lines -318 to +322
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"]
)

Copy link
Author

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)

@Motzumoto
Copy link
Contributor

I dont entirely suggest using sourcery since it will push breaking changes with little to no testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants