-
Notifications
You must be signed in to change notification settings - Fork 140
refactor(lint): add flake8-return rules #948
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
Open
onerandomusername
wants to merge
8
commits into
master
Choose a base branch
from
lint/flake8-return
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
18d64ba
enable some RET codes
onerandomusername 39319e9
fix all RET502 errors
onerandomusername bcbac41
fix all RET503 errors
onerandomusername bd922a4
ignore all RET504 errors
onerandomusername c396fa5
fix all RET505 errors
onerandomusername 11296e6
fix all RET506 errors
onerandomusername d033bfa
fix all RET507 errors
onerandomusername 73e5905
fix all RET508 errors
onerandomusername File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,6 +477,8 @@ async def edit( | |
# the payload will always be the proper channel payload | ||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore | ||
|
||
return None | ||
|
||
@utils.copy_doc(disnake.abc.GuildChannel.clone) | ||
async def clone( | ||
self, *, name: Optional[str] = None, reason: Optional[str] = None | ||
|
@@ -1447,6 +1449,8 @@ async def edit( | |
# the payload will always be the proper channel payload | ||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore | ||
|
||
return None | ||
|
||
async def delete_messages(self, messages: Iterable[Snowflake]) -> None: | ||
"""|coro| | ||
|
||
|
@@ -2196,6 +2200,8 @@ async def edit( | |
# the payload will always be the proper channel payload | ||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore | ||
|
||
return None | ||
|
||
async def delete_messages(self, messages: Iterable[Snowflake]) -> None: | ||
"""|coro| | ||
|
||
|
@@ -2626,6 +2632,8 @@ async def edit( | |
# the payload will always be the proper channel payload | ||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore | ||
|
||
return None | ||
|
||
@overload | ||
async def move( | ||
self, | ||
|
@@ -3298,6 +3306,8 @@ async def edit( | |
# the payload will always be the proper channel payload | ||
return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore | ||
|
||
return None | ||
|
||
@utils.copy_doc(disnake.abc.GuildChannel.clone) | ||
async def clone( | ||
self, *, name: Optional[str] = None, reason: Optional[str] = None | ||
|
@@ -3554,7 +3564,7 @@ async def create_thread( | |
|
||
if params.files and len(params.files) > 10: | ||
raise ValueError("files parameter must be a list of up to 10 elements") | ||
elif params.files and not all(isinstance(file, File) for file in params.files): | ||
if params.files and not all(isinstance(file, File) for file in params.files): | ||
raise TypeError("files parameter must be a list of File") | ||
|
||
channel_data = { | ||
|
@@ -4112,28 +4122,26 @@ def _guild_channel_factory(channel_type: int): | |
value = try_enum(ChannelType, channel_type) | ||
if value is ChannelType.text: | ||
return TextChannel, value | ||
elif value is ChannelType.voice: | ||
if value is ChannelType.voice: | ||
return VoiceChannel, value | ||
elif value is ChannelType.category: | ||
if value is ChannelType.category: | ||
return CategoryChannel, value | ||
elif value is ChannelType.news: | ||
if value is ChannelType.news: | ||
return TextChannel, value | ||
elif value is ChannelType.stage_voice: | ||
if value is ChannelType.stage_voice: | ||
return StageChannel, value | ||
elif value is ChannelType.forum: | ||
if value is ChannelType.forum: | ||
return ForumChannel, value | ||
else: | ||
return None, value | ||
return None, value | ||
Comment on lines
4122
to
+4135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be lookup tables - out of scope here though |
||
|
||
|
||
def _channel_factory(channel_type: int): | ||
cls, value = _guild_channel_factory(channel_type) | ||
if value is ChannelType.private: | ||
return DMChannel, value | ||
elif value is ChannelType.group: | ||
if value is ChannelType.group: | ||
return GroupChannel, value | ||
else: | ||
return cls, value | ||
return cls, value | ||
|
||
|
||
def _threaded_channel_factory(channel_type: int): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -154,18 +154,16 @@ async def is_owner(self, user: Union[disnake.User, disnake.Member]) -> bool: | |||||||
""" | ||||||||
if self.owner_id: | ||||||||
return user.id == self.owner_id | ||||||||
elif self.owner_ids: | ||||||||
if self.owner_ids: | ||||||||
return user.id in self.owner_ids | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
else: | ||||||||
app = await self.application_info() # type: ignore | ||||||||
if app.team: | ||||||||
self.owners = set(app.team.members) | ||||||||
self.owner_ids = ids = {m.id for m in app.team.members} | ||||||||
return user.id in ids | ||||||||
else: | ||||||||
self.owner = app.owner | ||||||||
self.owner_id = owner_id = app.owner.id | ||||||||
return user.id == owner_id | ||||||||
app = await self.application_info() # type: ignore | ||||||||
if app.team: | ||||||||
self.owners = set(app.team.members) | ||||||||
self.owner_ids = ids = {m.id for m in app.team.members} | ||||||||
return user.id in ids | ||||||||
self.owner = app.owner | ||||||||
self.owner_id = owner_id = app.owner.id | ||||||||
return user.id == owner_id | ||||||||
|
||||||||
# listener registration | ||||||||
|
||||||||
|
@@ -379,7 +377,7 @@ def remove_cog(self, name: str) -> Optional[Cog]: | |||||||
""" | ||||||||
cog = self.__cogs.pop(name, None) | ||||||||
if cog is None: | ||||||||
return | ||||||||
return None | ||||||||
|
||||||||
help_command: Optional[HelpCommand] = getattr(self, "_help_command", None) | ||||||||
if help_command and help_command.cog is cog: | ||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: the spacing here seems weird, whitespace above the
if
would make more sense, i.e.