Skip to content

Commit

Permalink
update per review
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Feb 20, 2023
1 parent 28d08b2 commit 9d129c0
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 37 deletions.
8 changes: 4 additions & 4 deletions disnake/enums.py
Expand Up @@ -734,15 +734,15 @@ def __str__(self) -> str:
# reference: https://discord.com/developers/docs/reference#locales
class Locale(Enum):
bg = "bg"
"Bulgarian | български"
"Bulgarian | български" # noqa: RUF001
cs = "cs"
"Czech | Čeština"
da = "da"
"Danish | Dansk"
de = "de"
"German | Deutsch"
el = "el"
"Greek | Ελληνικά"
"Greek | Ελληνικά" # noqa: RUF001
en_GB = "en-GB"
"English, UK | English, UK"
en_US = "en-US"
Expand Down Expand Up @@ -780,15 +780,15 @@ class Locale(Enum):
ro = "ro"
"Romanian, Romania | Română"
ru = "ru"
"Russian | Pусский"
"Russian | Pусский" # noqa: RUF001
sv_SE = "sv-SE"
"Swedish | Svenska"
th = "th"
"Thai | ไทย"
tr = "tr"
"Turkish | Türkçe"
uk = "uk"
"Ukrainian | Українська"
"Ukrainian | Українська" # noqa: RUF001
vi = "vi"
"Vietnamese | Tiếng Việt"
zh_CN = "zh-CN"
Expand Down
4 changes: 2 additions & 2 deletions disnake/ext/commands/base_core.py
Expand Up @@ -627,8 +627,8 @@ async def can_run(self, inter: ApplicationCommandInteraction) -> bool:
if not predicates:
# since we have no checks, then we just return True.
return True
else:
return await async_all(predicate(inter) for predicate in predicates) # type: ignore

return await async_all(predicate(inter) for predicate in predicates) # type: ignore
finally:
inter.application_command = original

Expand Down
4 changes: 2 additions & 2 deletions disnake/ext/commands/core.py
Expand Up @@ -1149,8 +1149,8 @@ async def can_run(self, ctx: Context) -> bool:
if not predicates:
# since we have no checks, then we just return True.
return True
else:
return await disnake.utils.async_all(predicate(ctx) for predicate in predicates) # type: ignore

return await disnake.utils.async_all(predicate(ctx) for predicate in predicates) # type: ignore
finally:
ctx.command = original

Expand Down
4 changes: 2 additions & 2 deletions disnake/ext/commands/ctx_menus_core.py
Expand Up @@ -125,7 +125,7 @@ async def __call__(
self, interaction: ApplicationCommandInteraction, target: Any = None, *args, **kwargs
) -> None:
# the target may just not be passed in
args = (target or interaction.target,) + args
args = (target or interaction.target, *args)
if self.cog is not None:
await safe_call(self.callback, self.cog, interaction, *args, **kwargs)
else:
Expand Down Expand Up @@ -221,7 +221,7 @@ async def __call__(
self, interaction: ApplicationCommandInteraction, target: Any = None, *args, **kwargs
) -> None:
# the target may just not be passed in
args = (target or interaction.target,) + args
args = (target or interaction.target, *args)
if self.cog is not None:
await safe_call(self.callback, self.cog, interaction, *args, **kwargs)
else:
Expand Down
4 changes: 2 additions & 2 deletions disnake/ext/commands/params.py
Expand Up @@ -629,8 +629,8 @@ async def convert_argument(self, inter: ApplicationCommandInteraction, argument:
argument = self.converter(inter, argument)
if inspect.isawaitable(argument):
return await argument
else:
return argument

return argument
except errors.CommandError:
raise
except Exception as e:
Expand Down
8 changes: 4 additions & 4 deletions disnake/ext/commands/view.py
Expand Up @@ -5,8 +5,8 @@
# map from opening quotes to closing quotes
_quotes = {
'"': '"',
"‘": "’",
"‚": "‛",
"‘": "’", # noqa: RUF001
"‚": "‛", # noqa: RUF001
"“": "”",
"„": "‟",
"⹂": "⹂",
Expand All @@ -15,10 +15,10 @@
"〝": "〞",
"﹁": "﹂",
"﹃": "﹄",
""": """,
""": """, # noqa: RUF001
"「": "」",
"«": "»",
"‹": "›",
"‹": "›", # noqa: RUF001
"《": "》",
"〈": "〉",
}
Expand Down
4 changes: 2 additions & 2 deletions disnake/interactions/application_command.py
Expand Up @@ -231,7 +231,7 @@ def _get_chain_and_kwargs(
for option in self.options:
if option.value is None:
# Extend the chain and collect kwargs in the nesting
return option._get_chain_and_kwargs(chain + (option.name,))
return option._get_chain_and_kwargs((*chain, option.name))
return chain, {o.name: o.value for o in self.options}
return chain, {}

Expand Down Expand Up @@ -316,7 +316,7 @@ def _get_chain_and_kwargs(
for option in self.options:
if option.value is None:
# Extend the chain and collect kwargs in the nesting
return option._get_chain_and_kwargs(chain + (option.name,))
return option._get_chain_and_kwargs((*chain, option.name))
return chain, {o.name: o.value for o in self.options}
return chain, {}

Expand Down
2 changes: 1 addition & 1 deletion disnake/state.py
Expand Up @@ -652,7 +652,7 @@ async def query_members(
presences=presences,
nonce=request.nonce,
)
return await asyncio.wait_for(request.wait(), timeout=30.0) # noqa: TRY300
return await asyncio.wait_for(request.wait(), timeout=30.0)
except asyncio.TimeoutError:
_log.warning(
"Timed out waiting for chunks with query %r and limit %d for guild_id %d",
Expand Down
2 changes: 1 addition & 1 deletion disnake/ui/select/channel.py
Expand Up @@ -62,7 +62,7 @@ class ChannelSelect(BaseSelect[ChannelSelectMenu, "InteractionChannel", V_co]):
A list of channels that have been selected by the user.
"""

__repr_attributes__: Tuple[str, ...] = BaseSelect.__repr_attributes__ + ("channel_types",)
__repr_attributes__: Tuple[str, ...] = (*BaseSelect.__repr_attributes__, "channel_types")

@overload
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion disnake/ui/select/string.py
Expand Up @@ -96,7 +96,7 @@ class StringSelect(BaseSelect[StringSelectMenu, str, V_co]):
A list of values that have been selected by the user.
"""

__repr_attributes__: Tuple[str, ...] = BaseSelect.__repr_attributes__ + ("options",)
__repr_attributes__: Tuple[str, ...] = (*BaseSelect.__repr_attributes__, "options")

@overload
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion disnake/utils.py
Expand Up @@ -1152,7 +1152,7 @@ def flatten_literal_params(parameters: Iterable[Any]) -> Tuple[Any, ...]:

def normalise_optional_params(parameters: Iterable[Any]) -> Tuple[Any, ...]:
none_cls = type(None)
return tuple(p for p in parameters if p is not none_cls) + (none_cls,)
return (*tuple(p for p in parameters if p is not none_cls), none_cls)


def evaluate_annotation(
Expand Down
6 changes: 2 additions & 4 deletions examples/basic_voice.py
Expand Up @@ -73,8 +73,7 @@ async def join(self, ctx, *, channel: disnake.VoiceChannel):
"""Joins a voice channel"""

if ctx.voice_client is not None:
await ctx.voice_client.move_to(channel)
return
return await ctx.voice_client.move_to(channel)

await channel.connect()

Expand Down Expand Up @@ -112,8 +111,7 @@ async def volume(self, ctx, volume: int):
"""Changes the player's volume"""

if ctx.voice_client is None:
await ctx.send("Not connected to a voice channel.")
return
return await ctx.send("Not connected to a voice channel.")

ctx.voice_client.source.volume = volume / 100
await ctx.send(f"Changed volume to {volume}%")
Expand Down
6 changes: 2 additions & 4 deletions examples/converters.py
Expand Up @@ -41,8 +41,7 @@ async def userinfo_error(ctx: commands.Context, error: commands.CommandError):
# If the conversion above fails for any reason, it will raise `commands.UserNotFound`
# so we handle this in this error handler:
if isinstance(error, commands.UserNotFound):
await ctx.send("Couldn't find that user.")
return
return await ctx.send("Couldn't find that user.")


@bot.command()
Expand Down Expand Up @@ -71,8 +70,7 @@ async def multiply(ctx: commands.Context, number: int, maybe: bool):
# See: https://docs.disnake.dev/en/stable/ext/commands/commands.html#bool

if maybe is True:
await ctx.send(str(number * 2))
return
return await ctx.send(str(number * 2))

await ctx.send(str(number * 5))

Expand Down
3 changes: 1 addition & 2 deletions examples/guessing_game.py
Expand Up @@ -29,8 +29,7 @@ def is_guess_message(m: disnake.Message):
try:
guess = await ctx.bot.wait_for("message", check=is_guess_message, timeout=10)
except asyncio.TimeoutError:
await ctx.send(f"Sorry, you took too long. The answer was {answer}.")
return
return await ctx.send(f"Sorry, you took too long. The answer was {answer}.")

if int(guess.content) == answer:
await ctx.send("You guessed correctly!")
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Expand Up @@ -69,13 +69,12 @@ select = [
# "SIM", # flake8-simplify
"TID251", # flake8-tidy-imports, replaces S404
# "TCH", # flake8-type-checking
# "RUF", # ruff specific exceptions
"RUF100", # unused noqa directive
"RUF", # ruff specific exceptions
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"T20", # flake8-print
"PGH", # pygrep-hooks
"TRY002", "TRY004","TRY300", # tryceratops
"TRY002", "TRY004", # tryceratops
]
ignore = [
# star imports
Expand All @@ -95,13 +94,13 @@ ignore = [
"B026", # backwards star-arg unpacking
"E501", # line too long
"E731", # assigning lambdas to variables
"RUF004", # keyword args must be supplied after starred arguments
"T201", # print statements
]

[tool.ruff.per-file-ignores]
"disnake/__main__.py" = ["T201"]
"disnake/i18n.py" = ["B027"] # lib bug
"disnake/types/**.py" = ["TCH"]
"disnake/**.py" = ["PT"]
"examples/*.py" = ["B008", "T201", "PT"]
"examples/basic_voice.py" = ["S104"]
Expand All @@ -113,7 +112,6 @@ ignore = [
fixture-parentheses = false
mark-parentheses = false

[tool.ruff.flake8-tidy-imports]
[tool.ruff.flake8-tidy-imports.banned-api]
"subprocess".msg = "Consider possible security implications associated with the subprocess module." # replaces S404

Expand Down

0 comments on commit 9d129c0

Please sign in to comment.