Skip to content
Closed
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
4 changes: 1 addition & 3 deletions hikari/api/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import attr

from hikari import undefined
from hikari.internal import attr_extensions

if typing.TYPE_CHECKING:
from hikari import applications as application_models
Expand All @@ -53,8 +52,7 @@
from hikari.internal import data_binding


@attr_extensions.with_copy
@attr.define(weakref_slot=False)
@attr.frozen(weakref_slot=False)
class GatewayGuildDefinition:
"""A structure for handling entities within guild create and update events."""

Expand Down
2 changes: 1 addition & 1 deletion hikari/api/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def dispatch(self, event: EventT_inv) -> asyncio.Future[typing.Any]:
from hikari.users import User
from hikari.snowflakes import Snowflake

@attr.define()
@attr.frozen()
class EveryoneMentionedEvent(Event):
app: RESTAware = attr.field()

Expand Down
42 changes: 12 additions & 30 deletions hikari/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from hikari import snowflakes
from hikari import urls
from hikari import users
from hikari.internal import attr_extensions
from hikari.internal import enums
from hikari.internal import routes

Expand Down Expand Up @@ -232,8 +231,7 @@ class ConnectionVisibility(int, enums.Enum):
"""Everyone can see the connection."""


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class OwnConnection:
"""Represents a user's connection with a third party account.

Expand Down Expand Up @@ -272,7 +270,7 @@ class OwnConnection:
"""The visibility of the connection."""


@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class OwnGuild(guilds.PartialGuild):
"""Represents a user bound partial guild object."""

Expand All @@ -297,8 +295,7 @@ class TeamMembershipState(int, enums.Enum):
"""Denotes the user has accepted the invite and is now a member."""


@attr_extensions.with_copy
@attr.define(eq=False, hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(eq=False, hash=False, kw_only=True, weakref_slot=False)
class TeamMember(users.User):
"""Represents a member of a Team."""

Expand Down Expand Up @@ -347,10 +344,6 @@ def flags(self) -> users.UserFlag:
def id(self) -> snowflakes.Snowflake:
return self.user.id

@id.setter
def id(self, value: snowflakes.Snowflake) -> typing.NoReturn:
raise TypeError("Cannot mutate the ID of a member")

@property
def is_bot(self) -> bool:
return self.user.is_bot
Expand Down Expand Up @@ -380,14 +373,11 @@ def __eq__(self, other: object) -> bool:
return self.user == other


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class Team(snowflakes.Unique):
"""Represents a development team, along with all its members."""

app: traits.RESTAware = attr.field(
repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True}
)
app: traits.RESTAware = attr.field(repr=False, eq=False, hash=False)
"""The client application that models may use for procedures."""

id: snowflakes.Snowflake = attr.field(hash=True, repr=True)
Expand Down Expand Up @@ -461,14 +451,11 @@ def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optiona
)


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class Application(guilds.PartialApplication):
"""Represents the information of an Oauth2 Application."""

app: traits.RESTAware = attr.field(
repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True}
)
app: traits.RESTAware = attr.field(repr=False, eq=False, hash=False)
"""The client application that models may use for procedures."""

is_bot_public: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=True)
Expand Down Expand Up @@ -565,8 +552,7 @@ def make_cover_image_url(self, *, ext: str = "png", size: int = 4096) -> typing.
)


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class AuthorizationApplication(guilds.PartialApplication):
"""The application model found attached to `AuthorizationInformation`."""

Expand All @@ -592,8 +578,7 @@ class AuthorizationApplication(guilds.PartialApplication):
"""The URL of this application's privacy policy."""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class AuthorizationInformation:
"""Model for the data returned by Get Current Authorization Information."""

Expand All @@ -610,8 +595,7 @@ class AuthorizationInformation:
"""The user who has authorized this token if they included the `identify` scope."""


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class PartialOAuth2Token:
"""Model for partial OAuth2 token data returned by the API.

Expand All @@ -635,8 +619,7 @@ def __str__(self) -> str:
return self.access_token


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class OAuth2AuthorizationToken(PartialOAuth2Token):
"""Model for the OAuth2 token data returned by the authorization grant flow."""

Expand All @@ -658,8 +641,7 @@ class OAuth2AuthorizationToken(PartialOAuth2Token):
"""


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class OAuth2ImplicitToken(PartialOAuth2Token):
"""Model for the OAuth2 token data returned by the implicit grant flow."""

Expand Down
42 changes: 14 additions & 28 deletions hikari/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
"MessagePinEntryInfo",
]

import abc
import typing

import attr

from hikari import channels
from hikari import snowflakes
from hikari.internal import attr_extensions
from hikari.internal import collections
from hikari.internal import enums

Expand Down Expand Up @@ -126,8 +124,7 @@ class AuditLogChangeKey(str, enums.Enum):
"""Alias for "COLOR"""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class AuditLogChange:
"""Represents a change made to an audit log entry's target entity."""

Expand Down Expand Up @@ -182,16 +179,15 @@ class AuditLogEventType(int, enums.Enum):
INTEGRATION_DELETE = 82


@attr.define(hash=False, kw_only=True, weakref_slot=False)
class BaseAuditLogEntryInfo(abc.ABC):
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class BaseAuditLogEntryInfo:
"""A base object that all audit log entry info objects will inherit from."""

app: traits.RESTAware = attr.field(repr=False, eq=False, metadata={attr_extensions.SKIP_DEEP_COPY: True})
app: traits.RESTAware = attr.field(repr=False, eq=False)
"""The client application that models may use for procedures."""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class ChannelOverwriteEntryInfo(BaseAuditLogEntryInfo, snowflakes.Unique):
"""Represents the extra information for overwrite related audit log entries.

Expand All @@ -209,8 +205,7 @@ class ChannelOverwriteEntryInfo(BaseAuditLogEntryInfo, snowflakes.Unique):
"""The name of the role this overwrite targets, if it targets a role."""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class MessagePinEntryInfo(BaseAuditLogEntryInfo):
"""The extra information for message pin related audit log entries.

Expand Down Expand Up @@ -290,8 +285,7 @@ async def fetch_message(self) -> messages.Message:
return await self.app.rest.fetch_message(self.channel_id, self.message_id)


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class MemberPruneEntryInfo(BaseAuditLogEntryInfo):
"""Extra information attached to guild prune log entries."""

Expand All @@ -302,17 +296,15 @@ class MemberPruneEntryInfo(BaseAuditLogEntryInfo):
"""The number of members who were removed by this prune."""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class MessageBulkDeleteEntryInfo(BaseAuditLogEntryInfo):
"""Extra information for the message bulk delete audit entry."""

count: int = attr.field(repr=True)
"""The amount of messages that were deleted."""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class MessageDeleteEntryInfo(MessageBulkDeleteEntryInfo):
"""Extra information attached to the message delete audit entry."""

Expand Down Expand Up @@ -354,17 +346,15 @@ async def fetch_channel(self) -> channels.GuildTextChannel:
return channel


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class MemberDisconnectEntryInfo(BaseAuditLogEntryInfo):
"""Extra information for the voice chat member disconnect entry."""

count: int = attr.field(repr=True)
"""The amount of members who were disconnected from voice in this entry."""


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, weakref_slot=False)
class MemberMoveEntryInfo(MemberDisconnectEntryInfo):
"""Extra information for the voice chat based member move entry."""

Expand Down Expand Up @@ -406,14 +396,11 @@ async def fetch_channel(self) -> channels.GuildVoiceChannel:
return channel


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
@attr.frozen(hash=True, kw_only=True, weakref_slot=False)
class AuditLogEntry(snowflakes.Unique):
"""Represents an entry in a guild's audit log."""

app: traits.RESTAware = attr.field(
repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True}
)
app: traits.RESTAware = attr.field(repr=False, eq=False, hash=False)
"""The client application that models may use for procedures."""

id: snowflakes.Snowflake = attr.field(hash=True, repr=True)
Expand Down Expand Up @@ -470,8 +457,7 @@ async def fetch_user(self) -> typing.Optional[users_.User]:
return await self.app.rest.fetch_user(self.user_id)


@attr_extensions.with_copy
@attr.define(hash=False, kw_only=True, repr=False, weakref_slot=False)
@attr.frozen(hash=False, kw_only=True, repr=False, weakref_slot=False)
class AuditLog(typing.Sequence[AuditLogEntry]):
"""Represents a guilds audit log."""

Expand Down
Loading