Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ async def _edit(

if options:
return await self._state.http.edit_channel(self.id, reason=reason, **options)
return None

def _fill_overwrites(self, data: GuildChannelPayload) -> None:
self._overwrites = []
Expand Down
1 change: 1 addition & 0 deletions disnake/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def created_at(self) -> Optional[datetime.datetime]:
return datetime.datetime.fromtimestamp(
self._created_at / 1000, tz=datetime.timezone.utc
)
return None

@property
def start(self) -> Optional[datetime.datetime]:
Expand Down
2 changes: 1 addition & 1 deletion disnake/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload]) -> N
if attr == "$add":
self._handle_role(self.before, self.after, entry, elem["new_value"]) # type: ignore
continue
elif attr == "$remove":
if attr == "$remove":
self._handle_role(self.after, self.before, entry, elem["new_value"]) # type: ignore
continue

Expand Down
6 changes: 6 additions & 0 deletions disnake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ async def edit(
if payload is not None:
# 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 clone(
self,
Expand Down Expand Up @@ -1711,6 +1712,7 @@ async def edit(
if payload is not None:
# 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|
Expand Down Expand Up @@ -2568,6 +2570,7 @@ async def edit(
if payload is not None:
# 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|
Expand Down Expand Up @@ -3060,6 +3063,7 @@ async def edit(
if payload is not None:
# 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(
Expand Down Expand Up @@ -4223,6 +4227,7 @@ async def edit(
if payload is not None:
# 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 clone(
self,
Expand Down Expand Up @@ -4621,6 +4626,7 @@ async def edit(
if payload is not None:
# 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 clone(
self,
Expand Down
6 changes: 4 additions & 2 deletions disnake/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,10 +1317,11 @@ def stop_loop_on_completion(f) -> None:

if not future.cancelled():
try:
return future.result()
future.result()
except KeyboardInterrupt:
# I am unsure why this gets raised here but suppress it anyway
return None
pass
return

# properties

Expand Down Expand Up @@ -1458,6 +1459,7 @@ def get_stage_instance(self, id: int, /) -> Optional[StageInstance]:

if isinstance(channel, StageChannel):
return channel.instance
return None

def get_guild(self, id: int, /) -> Optional[Guild]:
"""Returns a guild with the given ID.
Expand Down
4 changes: 2 additions & 2 deletions disnake/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __getattr__(name: str) -> None:
"`EmptyEmbed` is deprecated and will be removed in a future version. Use `None` instead.",
stacklevel=2,
)
return None
return None # noqa: RET501
msg = f"module '{__name__}' has no attribute '{name}'"
raise AttributeError(msg)

Expand Down Expand Up @@ -233,7 +233,7 @@ def Empty(self) -> None:
"`Embed.Empty` is deprecated and will be removed in a future version. Use `None` instead.",
stacklevel=3,
)
return None
return None # noqa: RET501

@classmethod
def from_dict(cls, data: EmbedData) -> Self:
Expand Down
24 changes: 12 additions & 12 deletions disnake/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,18 @@ async def delete(self, *, reason: Optional[str] = None) -> None:
InvalidData
The emoji data is invalid and cannot be processed.
"""
if self.guild_id is None:
# this is an app emoji
if self.application_id is None:
# should never happen
msg = (
f"guild_id and application_id are both None when attempting to delete emoji with ID {self.id}."
" This may be a library bug! Open an issue on GitHub."
)
raise InvalidData(msg)

return await self._state.http.delete_app_emoji(self.application_id, self.id)
await self._state.http.delete_custom_emoji(self.guild_id, self.id, reason=reason)
if self.guild_id is not None:
await self._state.http.delete_custom_emoji(self.guild_id, self.id, reason=reason)
return
if self.application_id is not None:
await self._state.http.delete_app_emoji(self.application_id, self.id)
return
# should never happen
msg = (
f"guild_id and application_id are both None when attempting to delete emoji with ID {self.id}."
" This may be a library bug! Open an issue on GitHub."
)
raise InvalidData(msg)

async def edit(
self, *, name: str = MISSING, roles: List[Snowflake] = MISSING, reason: Optional[str] = None
Expand Down
4 changes: 2 additions & 2 deletions disnake/ext/commands/base_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def wrapped(*args, **kwargs):
except CommandError:
raise
except asyncio.CancelledError:
return
return None
except Exception as exc:
raise CommandInvokeError(exc) from exc
return ret
Expand Down Expand Up @@ -507,7 +507,7 @@ async def _call_local_error_handler(
self, inter: ApplicationCommandInteraction, error: CommandError
) -> Any:
if not self.has_error_handler():
return
return None

injected = wrap_callback(self.on_error)
if self.cog is not None:
Expand Down
3 changes: 1 addition & 2 deletions disnake/ext/commands/bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ async def get_prefix(bot, message):

def inner(bot: BotBase, msg: Message) -> List[str]:
r = list(prefixes)
r = when_mentioned(bot, msg) + r
return r
return when_mentioned(bot, msg) + r

return inner

Expand Down
2 changes: 1 addition & 1 deletion disnake/ext/commands/common_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,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:
Expand Down
2 changes: 2 additions & 0 deletions disnake/ext/commands/cooldowns.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def get_key(self, msg: Message) -> Any:
return (
msg.author.top_role if msg.guild and isinstance(msg.author, Member) else msg.channel
).id
return None

def __call__(self, msg: Message) -> Any:
return self.get_key(msg)
Expand Down Expand Up @@ -163,6 +164,7 @@ def update_rate_limit(self, current: Optional[float] = None) -> Optional[float]:

# we're not so decrement our tokens
self._tokens -= 1
return None

def reset(self) -> None:
"""Reset the cooldown to its initial state."""
Expand Down
3 changes: 1 addition & 2 deletions disnake/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,7 @@ def signature(self) -> str:
else f"[{name}={param.default}]..."
)
continue
else:
result.append(f"[{name}]")
result.append(f"[{name}]")

elif param.kind == param.VAR_POSITIONAL:
if self.require_var_positional:
Expand Down
8 changes: 4 additions & 4 deletions disnake/ext/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ async def send_bot_help(
The key of the mapping is the :class:`~.commands.Cog` that the command belongs to, or
:data:`None` if there isn't one, and the value is a list of commands that belongs to that cog.
"""
return None
return

async def send_cog_help(self, cog: Cog) -> None:
"""|coro|
Expand Down Expand Up @@ -742,7 +742,7 @@ async def send_cog_help(self, cog: Cog) -> None:
cog: :class:`Cog`
The cog that was requested for help.
"""
return None
return

async def send_group_help(self, group: Group[Any, ..., Any]) -> None:
"""|coro|
Expand Down Expand Up @@ -770,7 +770,7 @@ async def send_group_help(self, group: Group[Any, ..., Any]) -> None:
group: :class:`Group`
The group that was requested for help.
"""
return None
return

async def send_command_help(self, command: Command[Any, ..., Any]) -> None:
"""|coro|
Expand Down Expand Up @@ -808,7 +808,7 @@ async def send_command_help(self, command: Command[Any, ..., Any]) -> None:
command: :class:`Command`
The command that was requested for help.
"""
return None
return

async def prepare_help_command(self, ctx: Context[BotT], command: Optional[str] = None) -> None:
"""|coro|
Expand Down
1 change: 1 addition & 0 deletions disnake/ext/commands/interaction_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ def get_slash_command(
group = slash.children.get(chain[1])
if isinstance(group, SubCommandGroup):
return group.children.get(chain[2])
return None

def get_user_command(self, name: str) -> Optional[InvokableUserCommand]:
"""Gets an :class:`InvokableUserCommand` from the internal list
Expand Down
1 change: 1 addition & 0 deletions disnake/ext/commands/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def get_quoted_word(self) -> Optional[str]:
return "".join(result)

result.append(current)
return None

def __repr__(self) -> str:
return (
Expand Down
7 changes: 5 additions & 2 deletions disnake/ext/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def seconds(self) -> Optional[float]:
"""
if self._seconds is not MISSING:
return self._seconds
return None

@property
def minutes(self) -> Optional[float]:
Expand All @@ -242,6 +243,7 @@ def minutes(self) -> Optional[float]:
"""
if self._minutes is not MISSING:
return self._minutes
return None

@property
def hours(self) -> Optional[float]:
Expand All @@ -252,6 +254,7 @@ def hours(self) -> Optional[float]:
"""
if self._hours is not MISSING:
return self._hours
return None

@property
def time(self) -> Optional[List[datetime.time]]:
Expand All @@ -262,6 +265,7 @@ def time(self) -> Optional[List[datetime.time]]:
"""
if self._time is not MISSING:
return self._time.copy()
return None

@property
def current_loop(self) -> int:
Expand Down Expand Up @@ -630,8 +634,7 @@ def _get_time_parameter(
raise TypeError(msg)
ret.append(t if t.tzinfo is not None else t.replace(tzinfo=utc))

ret = sorted(set(ret)) # de-dupe and sort times
return ret
return sorted(set(ret)) # de-dupe and sort times

def change_interval(
self,
Expand Down
9 changes: 4 additions & 5 deletions disnake/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ def key(t: ByCategoryItem) -> Tuple[Tuple[int, int], List[GuildChannel]]:

def _resolve_channel(self, id: Optional[int], /) -> Optional[Union[GuildChannel, Thread]]:
if id is None:
return
return None

return self._channels.get(id) or self._threads.get(id)

Expand Down Expand Up @@ -2549,12 +2549,11 @@ def convert(d: GuildChannelPayload) -> GuildChannel:
if factory is None:
raise InvalidData("Unknown channel type {type} for channel ID {id}.".format_map(d))

channel = factory(
return factory(
guild=self,
state=self._state,
data=d, # type: ignore
)
return channel

return [convert(d) for d in data]

Expand Down Expand Up @@ -4039,10 +4038,9 @@ async def create_role(
fields["unicode_emoji"] = emoji

data = await self._state.http.create_role(self.id, reason=reason, **fields)
role = Role(guild=self, data=data, state=self._state)

# TODO: add to cache
return role
return Role(guild=self, data=data, state=self._state)

async def edit_role_positions(
self, positions: Dict[Snowflake, int], *, reason: Optional[str] = None
Expand Down Expand Up @@ -4668,6 +4666,7 @@ async def chunk(self, *, cache: bool = True) -> Optional[List[Member]]:

if not self._state.is_guild_evicted(self):
return await self._state.chunk_guild(self, cache=cache)
return None

async def query_members(
self,
Expand Down
3 changes: 2 additions & 1 deletion disnake/interactions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,8 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
Deleting the message failed.
"""
if self._state._interaction.is_expired():
return await super().delete(delay=delay)
await super().delete(delay=delay)
return
if delay is not None:

async def inner_call(delay: float = delay) -> None:
Expand Down
5 changes: 3 additions & 2 deletions disnake/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ def _copy(cls, member: Member) -> Self:
return self

async def _get_channel(self) -> DMChannel:
ch = await self.create_dm()
return ch
return await self.create_dm()

def _update(self, data: GuildMemberUpdateEvent) -> None:
# the nickname change is optional,
Expand Down Expand Up @@ -499,6 +498,7 @@ def _update_inner_user(self, user: UserPayload) -> Optional[Tuple[User, User]]:
) = modified
# Signal to dispatch on_user_update
return to_return, u
return None

@property
def status(self) -> Status:
Expand Down Expand Up @@ -664,6 +664,7 @@ def activity(self) -> Optional[ActivityTypes]:
"""
if self.activities:
return self.activities[0]
return None

def mentioned_in(self, message: Message) -> bool:
"""Whether the member is mentioned in the specified message.
Expand Down
Loading