Skip to content

Commit cb967cd

Browse files
committed
fix linting errors
1 parent 68167a8 commit cb967cd

File tree

6 files changed

+24
-26
lines changed

6 files changed

+24
-26
lines changed

discord_slash/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
:license: MIT
99
"""
1010

11-
from .client import SlashCommand
12-
from .model import SlashCommandOptionType
13-
from .context import SlashContext
14-
from .context import ComponentContext
15-
from .dpy_overrides import ComponentMessage
16-
from .utils import manage_commands
17-
from .utils import manage_components
18-
from .const import __version__
11+
from .client import SlashCommand # noqa: F401
12+
from .model import SlashCommandOptionType # noqa: F401
13+
from .context import SlashContext # noqa: F401
14+
from .context import ComponentContext # noqa: F401
15+
from .dpy_overrides import ComponentMessage # noqa: F401
16+
from .utils import manage_commands # noqa: F401
17+
from .utils import manage_components # noqa: F401
18+
from .const import __version__ # noqa: F401

discord_slash/client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from . import model
1010
from . import error
1111
from . import context
12-
from . import dpy_overrides
1312
from .utils import manage_commands
1413

1514

@@ -336,7 +335,7 @@ async def sync_all_commands(
336335
for cmd in existing_cmds:
337336
existing_by_name[cmd["name"]] = model.CommandData(**cmd)
338337

339-
if len(new_cmds) != len(existing_cmds):
338+
if len(new_cmds) != len(existing_cmds):
340339
changed = True
341340

342341
for command in new_cmds:
@@ -356,7 +355,7 @@ async def sync_all_commands(
356355
changed=True
357356
to_send.append(command)
358357

359-
358+
360359
if changed:
361360
self.logger.debug(f"Detected changes on {scope if scope is not None else 'global'}, updating them")
362361
existing_cmds = await self.req.put_slash_commands(slash_commands=to_send, guild_id=scope)
@@ -401,7 +400,7 @@ async def sync_all_commands(
401400
if existing_perms_model[new_perm["id"]] != model.GuildPermissionsData(**new_perm):
402401
changed = True
403402
break
404-
403+
405404
if changed:
406405
self.logger.debug(f"Detected permissions changes on {scope}, updating them")
407406
await self.req.update_guild_commands_permissions(scope, new_perms)
@@ -414,7 +413,7 @@ async def sync_all_commands(
414413
other_guilds = [guild.id for guild in self._discord.guilds if guild.id not in cmds["guild"]]
415414
# This is an extremly bad way to do this, because slash cmds can be in guilds the bot isn't in
416415
# But it's the only way until discord makes an endpoint to request all the guild with cmds registered.
417-
416+
418417
for guild in other_guilds:
419418
with suppress(discord.Forbidden):
420419
existing = await self.req.get_all_commands(guild_id = guild)
@@ -772,11 +771,11 @@ def wrapper(cmd):
772771
def permission(self, guild_id: int, permissions: list):
773772
"""
774773
Decorator that add permissions. This will set the permissions for a single guild, you can use it more than once for each command.
775-
:param guild_id: ID of the guild for the permissions.
774+
:param guild_id: ID of the guild for the permissions.
776775
:type guild_id: int
777776
:param permissions: Permission requirements of the slash command. Default ``None``.
778777
:type permissions: dict
779-
778+
780779
"""
781780
def wrapper(cmd):
782781
if not getattr(cmd, "__permissions__", None):

discord_slash/context.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,11 @@ async def edit_origin(self, **fields):
338338
if self.deferred:
339339
_json = await self._http.edit(_resp, self._token, files=files)
340340
self.deferred = False
341-
else:
342-
json_data = {
343-
"type": 7,
344-
"data": _resp
345-
}
346-
_json = await self._http.post_initial_response(json_data, self.interaction_id, self._token)
341+
else: # noqa: F841
342+
json_data = {"type": 7, "data": _resp}
343+
_json = await self._http.post_initial_response( # noqa: F841
344+
json_data, self.interaction_id, self._token
345+
)
347346
self.responded = True
348347
else:
349348
raise error.IncorrectFormat("Already responded")

discord_slash/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def post_initial_response(self, _resp, interaction_id, token):
131131
return self.command_response(token, False, "POST", interaction_id, json=_resp)
132132

133133
def command_response(self, token, use_webhook, method, interaction_id= None, url_ending = "", **kwargs):
134-
"""
134+
r"""
135135
Sends a command response to discord (POST, PATCH, DELETE)
136136
137137
:param token: Interaction token

discord_slash/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async def _concurrency_checks(self, ctx):
177177
try:
178178
# cooldown checks
179179
self._prepare_cooldowns(ctx)
180-
except:
180+
except Exception:
181181
if self._max_concurrency is not None:
182182
await self._max_concurrency.release(ctx)
183183
raise
@@ -498,7 +498,7 @@ class GuildPermissionsData:
498498
Slash permissions data for a command in a guild.
499499
500500
:ivar id: Command id, provided by discord.
501-
:ivar guild_id: Guild id that the permissions are in.
501+
:ivar guild_id: Guild id that the permissions are in.
502502
:ivar permissions: List of permissions dict.
503503
"""
504504
def __init__(self, id, guild_id, permissions, **kwargs):

discord_slash/utils/manage_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def create_option(name: str,
269269
270270
.. note::
271271
``choices`` must either be a list of `option type dicts <https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice>`_
272-
or a list of single string values.
272+
or a list of single string values.
273273
"""
274274
if not isinstance(option_type, int) or isinstance(option_type, bool): #Bool values are a subclass of int
275275
original_type = option_type
@@ -320,7 +320,7 @@ def generate_options(function: Callable, description: str = "No description.", c
320320
args = getattr(param.annotation, "__args__", None)
321321
if args:
322322
param = param.replace(annotation=args[0])
323-
required = not args[-1] is type(None)
323+
required = not isinstance(args[-1], type(None))
324324

325325
option_type = SlashCommandOptionType.from_type(param.annotation) or SlashCommandOptionType.STRING
326326
name = param.name if not connector else connector[param.name]

0 commit comments

Comments
 (0)