Skip to content
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

[pre-commit.ci] pre-commit autoupdate #1753

Merged
merged 7 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
# - --remove-duplicate-keys
# - --remove-unused-variables
- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
rev: v3.2.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand All @@ -30,7 +30,7 @@ repos:
# See https://github.com/psf/black/issues/2188#issuecomment-1289317647 for why we can't use the --preview flag.
args: [--safe, --quiet]
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
rev: 1.0.1
rev: v1.1.1
hooks:
- id: black-disable-checker
# - repo: https://github.com/PyCQA/flake8
Expand Down Expand Up @@ -74,12 +74,12 @@ repos:
# - id: mypy

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.3
rev: v3.0.0-alpha.4
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: 93b15ca # TODO: Change this when v8.0 is released
rev: v0.7.2 # TODO: Change this when v8.0 is released
BobDotCom marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: pydocstringformatter
args:
Expand Down
12 changes: 8 additions & 4 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ class User(Snowflake, Protocol):

@property
def display_name(self) -> str:
""":class:`str`: Returns the user's display name."""
""":class:`str`: Returns the user's display name.
"""
raise NotImplementedError

@property
def mention(self) -> str:
""":class:`str`: Returns a string that allows you to mention the given user."""
""":class:`str`: Returns a string that allows you to mention the given user.
"""
raise NotImplementedError


Expand Down Expand Up @@ -524,7 +526,8 @@ def changed_roles(self) -> list[Role]:

@property
def mention(self) -> str:
""":class:`str`: The string that allows you to mention the channel."""
""":class:`str`: The string that allows you to mention the channel.
"""
return f"<#{self.id}>"

@property
Expand All @@ -537,7 +540,8 @@ def jump_url(self) -> str:

@property
def created_at(self) -> datetime:
""":class:`datetime.datetime`: Returns the channel's creation time in UTC."""
""":class:`datetime.datetime`: Returns the channel's creation time in UTC.
"""
return utils.snowflake_time(self.id)

def overwrites_for(self, obj: Role | User) -> PermissionOverwrite:
Expand Down
54 changes: 36 additions & 18 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ def to_dict(self) -> dict[str, Any]:

@property
def start(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user started doing this activity in UTC, if applicable."""
"""Optional[:class:`datetime.datetime`]: When the user started doing this activity in UTC, if applicable.
"""
try:
timestamp = self.timestamps["start"] / 1000
except KeyError:
Expand All @@ -289,7 +290,8 @@ def start(self) -> datetime.datetime | None:

@property
def end(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user will stop doing this activity in UTC, if applicable."""
"""Optional[:class:`datetime.datetime`]: When the user will stop doing this activity in UTC, if applicable.
"""
try:
timestamp = self.timestamps["end"] / 1000
except KeyError:
Expand All @@ -299,7 +301,8 @@ def end(self) -> datetime.datetime | None:

@property
def large_image_url(self) -> str | None:
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity if applicable."""
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity if applicable.
"""
if self.application_id is None:
return None

Expand All @@ -312,7 +315,8 @@ def large_image_url(self) -> str | None:

@property
def small_image_url(self) -> str | None:
"""Optional[:class:`str`]: Returns a URL pointing to the small image asset of this activity if applicable."""
"""Optional[:class:`str`]: Returns a URL pointing to the small image asset of this activity if applicable.
"""
if self.application_id is None:
return None

Expand All @@ -325,12 +329,14 @@ def small_image_url(self) -> str | None:

@property
def large_image_text(self) -> str | None:
"""Optional[:class:`str`]: Returns the large image asset hover text of this activity if applicable."""
"""Optional[:class:`str`]: Returns the large image asset hover text of this activity if applicable.
"""
return self.assets.get("large_text", None)

@property
def small_image_text(self) -> str | None:
"""Optional[:class:`str`]: Returns the small image asset hover text of this activity if applicable."""
"""Optional[:class:`str`]: Returns the small image asset hover text of this activity if applicable.
"""
return self.assets.get("small_text", None)


Expand Down Expand Up @@ -393,7 +399,8 @@ def type(self) -> ActivityType:

@property
def start(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user started playing this game in UTC, if applicable."""
"""Optional[:class:`datetime.datetime`]: When the user started playing this game in UTC, if applicable.
"""
if self._start:
return datetime.datetime.fromtimestamp(
self._start / 1000, tz=datetime.timezone.utc
Expand All @@ -402,7 +409,8 @@ def start(self) -> datetime.datetime | None:

@property
def end(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user will stop playing this game in UTC, if applicable."""
"""Optional[:class:`datetime.datetime`]: When the user will stop playing this game in UTC, if applicable.
"""
if self._end:
return datetime.datetime.fromtimestamp(
self._end / 1000, tz=datetime.timezone.utc
Expand Down Expand Up @@ -643,7 +651,8 @@ def to_dict(self) -> dict[str, Any]:

@property
def name(self) -> str:
""":class:`str`: The activity's name. This will always return "Spotify"."""
""":class:`str`: The activity's name. This will always return "Spotify".
"""
return "Spotify"

def __eq__(self, other: Any) -> bool:
Expand Down Expand Up @@ -671,12 +680,14 @@ def __repr__(self) -> str:

@property
def title(self) -> str:
""":class:`str`: The title of the song being played."""
""":class:`str`: The title of the song being played.
"""
return self._details

@property
def artists(self) -> list[str]:
"""List[:class:`str`]: The artists of the song being played."""
"""List[:class:`str`]: The artists of the song being played.
"""
return self._state.split("; ")

@property
Expand All @@ -690,12 +701,14 @@ def artist(self) -> str:

@property
def album(self) -> str:
""":class:`str`: The album that the song being played belongs to."""
""":class:`str`: The album that the song being played belongs to.
"""
return self._assets.get("large_text", "")

@property
def album_cover_url(self) -> str:
""":class:`str`: The album cover image URL from Spotify's CDN."""
""":class:`str`: The album cover image URL from Spotify's CDN.
"""
large_image = self._assets.get("large_image", "")
if large_image[:8] != "spotify:":
return ""
Expand All @@ -704,7 +717,8 @@ def album_cover_url(self) -> str:

@property
def track_id(self) -> str:
""":class:`str`: The track ID used by Spotify to identify this song."""
""":class:`str`: The track ID used by Spotify to identify this song.
"""
return self._sync_id

@property
Expand All @@ -717,26 +731,30 @@ def track_url(self) -> str:

@property
def start(self) -> datetime.datetime:
""":class:`datetime.datetime`: When the user started playing this song in UTC."""
""":class:`datetime.datetime`: When the user started playing this song in UTC.
"""
return datetime.datetime.fromtimestamp(
self._timestamps["start"] / 1000, tz=datetime.timezone.utc
)

@property
def end(self) -> datetime.datetime:
""":class:`datetime.datetime`: When the user will stop playing this song in UTC."""
""":class:`datetime.datetime`: When the user will stop playing this song in UTC.
"""
return datetime.datetime.fromtimestamp(
self._timestamps["end"] / 1000, tz=datetime.timezone.utc
)

@property
def duration(self) -> datetime.timedelta:
""":class:`datetime.timedelta`: The duration of the song being played."""
""":class:`datetime.timedelta`: The duration of the song being played.
"""
return self.end - self.start

@property
def party_id(self) -> str:
""":class:`str`: The party ID of the listening party."""
""":class:`str`: The party ID of the listening party.
"""
return self._party.get("id", "")


Expand Down
6 changes: 4 additions & 2 deletions discord/appinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def __repr__(self) -> str:

@property
def icon(self) -> Asset | None:
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any."""
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any.
"""
if self._icon is None:
return None
return Asset._from_icon(self._state, self.id, self._icon, path="app")
Expand Down Expand Up @@ -253,7 +254,8 @@ def __repr__(self) -> str:

@property
def icon(self) -> Asset | None:
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any."""
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any.
"""
if self._icon is None:
return None
return Asset._from_icon(self._state, self.id, self._icon, path="app")
9 changes: 6 additions & 3 deletions discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,19 @@ def __hash__(self):

@property
def url(self) -> str:
""":class:`str`: Returns the underlying URL of the asset."""
""":class:`str`: Returns the underlying URL of the asset.
"""
return self._url

@property
def key(self) -> str:
""":class:`str`: Returns the identifying key of the asset."""
""":class:`str`: Returns the identifying key of the asset.
"""
return self._key

def is_animated(self) -> bool:
""":class:`bool`: Returns whether the asset is animated."""
""":class:`bool`: Returns whether the asset is animated.
"""
return self._animated

def replace(
Expand Down
15 changes: 10 additions & 5 deletions discord/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ def __repr__(self) -> str:

@utils.cached_property
def created_at(self) -> datetime.datetime:
""":class:`datetime.datetime`: Returns the entry's creation time in UTC."""
""":class:`datetime.datetime`: Returns the entry's creation time in UTC.
"""
return utils.snowflake_time(self.id)

@utils.cached_property
Expand Down Expand Up @@ -557,24 +558,28 @@ def target(

@utils.cached_property
def category(self) -> enums.AuditLogActionCategory:
"""Optional[:class:`AuditLogActionCategory`]: The category of the action, if applicable."""
"""Optional[:class:`AuditLogActionCategory`]: The category of the action, if applicable.
"""
return self.action.category

@utils.cached_property
def changes(self) -> AuditLogChanges:
""":class:`AuditLogChanges`: The list of changes this entry has."""
""":class:`AuditLogChanges`: The list of changes this entry has.
"""
obj = AuditLogChanges(self, self._changes, state=self._state)
del self._changes
return obj

@utils.cached_property
def before(self) -> AuditLogDiff:
""":class:`AuditLogDiff`: The target's prior state."""
""":class:`AuditLogDiff`: The target's prior state.
"""
return self.changes.before

@utils.cached_property
def after(self) -> AuditLogDiff:
""":class:`AuditLogDiff`: The target's subsequent state."""
""":class:`AuditLogDiff`: The target's subsequent state.
"""
return self.changes.after

def _convert_target_guild(self, target_id: int) -> Guild:
Expand Down
6 changes: 4 additions & 2 deletions discord/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,14 @@ def __str__(self) -> str:

@cached_property
def guild(self) -> Guild | None:
"""Optional[:class:`Guild`]: The guild this rule belongs to."""
"""Optional[:class:`Guild`]: The guild this rule belongs to.
"""
return self._state._get_guild(self.guild_id)

@cached_property
def creator(self) -> Member | None:
"""Optional[:class:`Member`]: The member who created this rule."""
"""Optional[:class:`Member`]: The member who created this rule.
"""
if self.guild is None:
return None
return self.guild.get_member(self.creator_id)
Expand Down