Skip to content

Commit a4b393d

Browse files
lint(docs): add basic pydocstyle rules (DisnakeDev#957)
Add some pydocstyle rules to the ruff configuration. These rules are all automatically fixed, and there was no manual changes. This should make it easy to add, because merge conflicts can be fixed by just running ruff.
1 parent e7db034 commit a4b393d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+214
-454
lines changed

disnake/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-License-Identifier: MIT
22

3-
"""
4-
Discord API Wrapper
3+
"""Discord API Wrapper
54
~~~~~~~~~~~~~~~~~~~
65
76
A basic wrapper for the Discord API.

disnake/abc.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ def _fill_overwrites(self, data: GuildChannelPayload) -> None:
483483
@property
484484
def changed_roles(self) -> List[Role]:
485485
"""List[:class:`.Role`]: Returns a list of roles that have been overridden from
486-
their default values in the :attr:`.Guild.roles` attribute."""
486+
their default values in the :attr:`.Guild.roles` attribute.
487+
"""
487488
ret = []
488489
g = self.guild
489490
for overwrite in filter(lambda o: o.is_role(), self._overwrites):
@@ -603,8 +604,7 @@ def flags(self) -> ChannelFlags:
603604

604605
@property
605606
def jump_url(self) -> str:
606-
"""
607-
A URL that can be used to jump to this channel.
607+
"""A URL that can be used to jump to this channel.
608608
609609
.. versionadded:: 2.4
610610
@@ -881,8 +881,7 @@ async def set_permissions(
881881
async def set_permissions(
882882
self, target, *, overwrite=MISSING, reason=None, **permissions
883883
) -> None:
884-
"""
885-
|coro|
884+
"""|coro|
886885
887886
Sets the channel specific permission overwrites for a target in the
888887
channel.

disnake/activity.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,16 @@ def type(self) -> Literal[ActivityType.listening]:
610610
def colour(self) -> Colour:
611611
""":class:`Colour`: Returns the Spotify integration colour, as a :class:`Colour`.
612612
613-
There is an alias for this named :attr:`color`"""
613+
There is an alias for this named :attr:`color`
614+
"""
614615
return Colour(0x1DB954)
615616

616617
@property
617618
def color(self) -> Colour:
618619
""":class:`Colour`: Returns the Spotify integration colour, as a :class:`Colour`.
619620
620-
There is an alias for this named :attr:`colour`"""
621+
There is an alias for this named :attr:`colour`
622+
"""
621623
return self.colour
622624

623625
def to_dict(self) -> Dict[str, Any]:

disnake/app_commands.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ def add_option(
364364
max_length: Optional[int] = None,
365365
) -> None:
366366
"""Adds an option to the current list of options,
367-
parameters are the same as for :class:`Option`."""
367+
parameters are the same as for :class:`Option`.
368+
"""
368369
type = type or OptionType.string
369370
self.options.append(
370371
Option(
@@ -428,8 +429,7 @@ def localize(self, store: LocalizationProtocol) -> None:
428429

429430

430431
class ApplicationCommand(ABC):
431-
"""
432-
The base class for application commands.
432+
"""The base class for application commands.
433433
434434
The following classes implement this ABC:
435435
@@ -580,8 +580,7 @@ def _update_common(self, data: ApplicationCommandPayload) -> None:
580580

581581

582582
class UserCommand(ApplicationCommand):
583-
"""
584-
A user context menu command.
583+
"""A user context menu command.
585584
586585
Attributes
587586
----------
@@ -624,8 +623,7 @@ def __init__(
624623

625624

626625
class APIUserCommand(UserCommand, _APIApplicationCommandMixin):
627-
"""
628-
A user context menu command returned by the API.
626+
"""A user context menu command returned by the API.
629627
630628
.. versionadded:: 2.4
631629
@@ -677,8 +675,7 @@ def from_dict(cls, data: ApplicationCommandPayload) -> Self:
677675

678676

679677
class MessageCommand(ApplicationCommand):
680-
"""
681-
A message context menu command
678+
"""A message context menu command
682679
683680
Attributes
684681
----------
@@ -721,8 +718,7 @@ def __init__(
721718

722719

723720
class APIMessageCommand(MessageCommand, _APIApplicationCommandMixin):
724-
"""
725-
A message context menu command returned by the API.
721+
"""A message context menu command returned by the API.
726722
727723
.. versionadded:: 2.4
728724
@@ -774,8 +770,7 @@ def from_dict(cls, data: ApplicationCommandPayload) -> Self:
774770

775771

776772
class SlashCommand(ApplicationCommand):
777-
"""
778-
The base class for building slash commands.
773+
"""The base class for building slash commands.
779774
780775
Attributes
781776
----------
@@ -905,8 +900,7 @@ def localize(self, store: LocalizationProtocol) -> None:
905900

906901

907902
class APISlashCommand(SlashCommand, _APIApplicationCommandMixin):
908-
"""
909-
A slash command returned by the API.
903+
"""A slash command returned by the API.
910904
911905
.. versionadded:: 2.4
912906

disnake/audit_logs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,7 @@ class _AuditLogProxyAutoModBlockMessage:
507507

508508

509509
class AuditLogEntry(Hashable):
510-
"""
511-
Represents an Audit Log entry.
510+
"""Represents an Audit Log entry.
512511
513512
You retrieve these via :meth:`Guild.audit_logs`.
514513

disnake/automod.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060

6161

6262
class AutoModAction:
63-
"""
64-
A base class for auto moderation actions.
63+
"""A base class for auto moderation actions.
6564
6665
This class is not meant to be instantiated by the user.
6766
The user-constructible subclasses are:
@@ -111,8 +110,7 @@ def to_dict(self) -> AutoModActionPayload:
111110

112111

113112
class AutoModBlockMessageAction(AutoModAction):
114-
"""
115-
Represents an auto moderation action that blocks content from being sent.
113+
"""Represents an auto moderation action that blocks content from being sent.
116114
117115
.. versionadded:: 2.6
118116
@@ -154,8 +152,7 @@ def __repr__(self) -> str:
154152

155153

156154
class AutoModSendAlertAction(AutoModAction):
157-
"""
158-
Represents an auto moderation action that sends an alert to a channel.
155+
"""Represents an auto moderation action that sends an alert to a channel.
159156
160157
.. versionadded:: 2.6
161158
@@ -190,8 +187,7 @@ def __repr__(self) -> str:
190187

191188

192189
class AutoModTimeoutAction(AutoModAction):
193-
"""
194-
Represents an auto moderation action that times out the user.
190+
"""Represents an auto moderation action that times out the user.
195191
196192
.. versionadded:: 2.6
197193
@@ -221,16 +217,16 @@ def __init__(self, duration: Union[int, timedelta]) -> None:
221217
@property
222218
def duration(self) -> int:
223219
""":class:`int`: The duration (in seconds) for which to timeout
224-
the user when the rule is triggered."""
220+
the user when the rule is triggered.
221+
"""
225222
return self._metadata["duration_seconds"]
226223

227224
def __repr__(self) -> str:
228225
return f"<{type(self).__name__} duration={self.duration!r}>"
229226

230227

231228
class AutoModTriggerMetadata:
232-
"""
233-
Metadata for an auto moderation trigger.
229+
"""Metadata for an auto moderation trigger.
234230
235231
Based on the trigger type, different fields can be used with various limits:
236232
@@ -342,8 +338,7 @@ def with_changes(
342338
allow_list: Optional[Sequence[str]] = MISSING,
343339
mention_total_limit: Optional[int] = MISSING,
344340
) -> Self:
345-
"""
346-
Returns a new instance with the given changes applied.
341+
"""Returns a new instance with the given changes applied.
347342
All other fields will be kept intact.
348343
349344
Returns
@@ -406,8 +401,7 @@ def __repr__(self) -> str:
406401

407402

408403
class AutoModRule:
409-
"""
410-
Represents an auto moderation rule.
404+
"""Represents an auto moderation rule.
411405
412406
.. versionadded:: 2.6
413407
@@ -478,7 +472,8 @@ def __init__(self, *, data: AutoModRulePayload, guild: Guild) -> None:
478472
@property
479473
def actions(self) -> List[AutoModAction]:
480474
"""List[Union[:class:`AutoModBlockMessageAction`, :class:`AutoModSendAlertAction`, :class:`AutoModTimeoutAction`, :class:`AutoModAction`]]:
481-
The list of actions that will execute if a matching event triggered this rule."""
475+
The list of actions that will execute if a matching event triggered this rule.
476+
"""
482477
return list(self._actions) # return a copy
483478

484479
@property
@@ -593,7 +588,6 @@ async def edit(
593588
:class:`AutoModRule`
594589
The newly updated auto moderation rule.
595590
"""
596-
597591
payload: EditAutoModRulePayload = {}
598592

599593
if name is not MISSING:
@@ -748,14 +742,16 @@ def channel(self) -> Optional[Union[GuildChannel, Thread]]:
748742
def message(self) -> Optional[Message]:
749743
"""Optional[:class:`Message`]: The message that matched, if any.
750744
Not available if the message was blocked, if the content was not part of a message,
751-
or if the message was not found in the message cache."""
745+
or if the message was not found in the message cache.
746+
"""
752747
return self.guild._state._get_message(self.message_id)
753748

754749
@property
755750
def alert_message(self) -> Optional[Message]:
756751
"""Optional[:class:`Message`]: The alert message sent as a result of this action, if any.
757752
Only available if :attr:`action.type <AutoModAction.type>` is :attr:`~AutoModActionType.send_alert_message`
758-
and the message was found in the message cache."""
753+
and the message was found in the message cache.
754+
"""
759755
return self.guild._state._get_message(self.alert_message_id)
760756

761757

disnake/channel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,8 +3825,7 @@ def created_at(self) -> datetime.datetime:
38253825

38263826
@property
38273827
def jump_url(self) -> str:
3828-
"""
3829-
A URL that can be used to jump to this channel.
3828+
"""A URL that can be used to jump to this channel.
38303829
38313830
.. versionadded:: 2.4
38323831
"""

disnake/client.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ def __repr__(self) -> str:
183183

184184

185185
class GatewayParams(NamedTuple):
186-
"""
187-
Container type for configuring gateway connections.
186+
"""Container type for configuring gateway connections.
188187
189188
.. versionadded:: 2.6
190189
@@ -203,8 +202,7 @@ class GatewayParams(NamedTuple):
203202

204203

205204
class Client:
206-
"""
207-
Represents a client connection that connects to Discord.
205+
"""Represents a client connection that connects to Discord.
208206
This class is used to interact with the Discord WebSocket and API.
209207
210208
A number of options can be passed to the :class:`Client`.
@@ -1383,8 +1381,7 @@ def get_guild_application_commands(self, guild_id: int) -> List[APIApplicationCo
13831381
return list(data.values())
13841382

13851383
def get_guild_slash_commands(self, guild_id: int) -> List[APISlashCommand]:
1386-
"""
1387-
Returns a list of all slash commands in the guild with the given ID.
1384+
"""Returns a list of all slash commands in the guild with the given ID.
13881385
13891386
Parameters
13901387
----------
@@ -1400,8 +1397,7 @@ def get_guild_slash_commands(self, guild_id: int) -> List[APISlashCommand]:
14001397
return [cmd for cmd in data.values() if isinstance(cmd, APISlashCommand)]
14011398

14021399
def get_guild_user_commands(self, guild_id: int) -> List[APIUserCommand]:
1403-
"""
1404-
Returns a list of all user commands in the guild with the given ID.
1400+
"""Returns a list of all user commands in the guild with the given ID.
14051401
14061402
Parameters
14071403
----------
@@ -1417,8 +1413,7 @@ def get_guild_user_commands(self, guild_id: int) -> List[APIUserCommand]:
14171413
return [cmd for cmd in data.values() if isinstance(cmd, APIUserCommand)]
14181414

14191415
def get_guild_message_commands(self, guild_id: int) -> List[APIMessageCommand]:
1420-
"""
1421-
Returns a list of all message commands in the guild with the given ID.
1416+
"""Returns a list of all message commands in the guild with the given ID.
14221417
14231418
Parameters
14241419
----------
@@ -1434,8 +1429,7 @@ def get_guild_message_commands(self, guild_id: int) -> List[APIMessageCommand]:
14341429
return [cmd for cmd in data.values() if isinstance(cmd, APIMessageCommand)]
14351430

14361431
def get_global_command(self, id: int) -> Optional[APIApplicationCommand]:
1437-
"""
1438-
Returns a global application command with the given ID.
1432+
"""Returns a global application command with the given ID.
14391433
14401434
Parameters
14411435
----------
@@ -1450,8 +1444,7 @@ def get_global_command(self, id: int) -> Optional[APIApplicationCommand]:
14501444
return self._connection._get_global_application_command(id)
14511445

14521446
def get_guild_command(self, guild_id: int, id: int) -> Optional[APIApplicationCommand]:
1453-
"""
1454-
Returns a guild application command with the given guild ID and application command ID.
1447+
"""Returns a guild application command with the given guild ID and application command ID.
14551448
14561449
Parameters
14571450
----------
@@ -1470,8 +1463,7 @@ def get_guild_command(self, guild_id: int, id: int) -> Optional[APIApplicationCo
14701463
def get_global_command_named(
14711464
self, name: str, cmd_type: Optional[ApplicationCommandType] = None
14721465
) -> Optional[APIApplicationCommand]:
1473-
"""
1474-
Returns a global application command matching the given name.
1466+
"""Returns a global application command matching the given name.
14751467
14761468
Parameters
14771469
----------
@@ -1490,8 +1482,7 @@ def get_global_command_named(
14901482
def get_guild_command_named(
14911483
self, guild_id: int, name: str, cmd_type: Optional[ApplicationCommandType] = None
14921484
) -> Optional[APIApplicationCommand]:
1493-
"""
1494-
Returns a guild application command matching the given name.
1485+
"""Returns a guild application command matching the given name.
14951486
14961487
Parameters
14971488
----------

0 commit comments

Comments
 (0)