Skip to content

Commit

Permalink
refactor!: move to MISSING and Maybe syntax
Browse files Browse the repository at this point in the history
The migration will be slow as it's not easy going over 600 mentions of a keyword.
  • Loading branch information
VincentRPS committed Apr 10, 2023
1 parent c813084 commit 086a2a3
Show file tree
Hide file tree
Showing 42 changed files with 986 additions and 1,039 deletions.
8 changes: 3 additions & 5 deletions docs/api/core.rst
Expand Up @@ -54,9 +54,7 @@ Audit Log
Etcetera Classes
----------------

Undefined
~~~~~~~~~

.. autoclass:: UndefinedType
Missing
~~~~~~~

.. autoclass:: UNDEFINED
.. autoclass:: MISSING
2 changes: 1 addition & 1 deletion examples/interactions/commands/application_commands.py
Expand Up @@ -6,7 +6,7 @@
# the guild id to deploy on. Often used for developing to
# avoid having to wait the extraneous amount of time Discord has for global
# commands
GUILD_ID: int | pycord.UndefinedType = pycord.UNDEFINED
GUILD_ID: int | pycord.MissingEnum = pycord.MISSING


# make a chat input command which
Expand Down
70 changes: 35 additions & 35 deletions pycord/api/routers/application_commands.py
Expand Up @@ -26,7 +26,7 @@
GuildApplicationCommandPermissions,
)
from ...types.interaction import InteractionResponse
from ...undefined import UNDEFINED, UndefinedType
from ...missing import MISSING, MissingEnum
from ...utils import remove_undefined
from ..route import Route
from .base import BaseRouter
Expand All @@ -48,14 +48,14 @@ async def create_global_application_command(
self,
application_id: Snowflake,
name: str,
name_localizations: dict[str, str] | UndefinedType = UNDEFINED,
description: str | UndefinedType = UNDEFINED,
description_localizations: dict[str, str] | UndefinedType = UNDEFINED,
options: list[ApplicationCommandOption] | UndefinedType = UNDEFINED,
default_member_permissions: str | None | UndefinedType = UNDEFINED,
dm_permission: UndefinedType | bool | None = UNDEFINED,
default_permission: bool | UndefinedType = UNDEFINED,
type: ATYPE | UndefinedType = UNDEFINED,
name_localizations: dict[str, str] | MissingEnum = MISSING,
description: str | MissingEnum = MISSING,
description_localizations: dict[str, str] | MissingEnum = MISSING,
options: list[ApplicationCommandOption] | MissingEnum = MISSING,
default_member_permissions: str | None | MissingEnum = MISSING,
dm_permission: MissingEnum | bool | None = MISSING,
default_permission: bool | MissingEnum = MISSING,
type: ATYPE | MissingEnum = MISSING,
):
data = remove_undefined(
name=name,
Expand All @@ -81,15 +81,15 @@ async def edit_global_application_command(
self,
application_id: Snowflake,
command_id: Snowflake,
name: str | UndefinedType = UNDEFINED,
name_localizations: dict[str, str] | UndefinedType = UNDEFINED,
description: str | UndefinedType = UNDEFINED,
description_localizations: dict[str, str] | UndefinedType = UNDEFINED,
options: list[ApplicationCommandOption] | UndefinedType = UNDEFINED,
default_member_permissions: str | None | UndefinedType = UNDEFINED,
dm_permission: UndefinedType | bool | None = UNDEFINED,
default_permission: bool | UndefinedType = UNDEFINED,
type: ATYPE | UndefinedType = UNDEFINED,
name: str | MissingEnum = MISSING,
name_localizations: dict[str, str] | MissingEnum = MISSING,
description: str | MissingEnum = MISSING,
description_localizations: dict[str, str] | MissingEnum = MISSING,
options: list[ApplicationCommandOption] | MissingEnum = MISSING,
default_member_permissions: str | None | MissingEnum = MISSING,
dm_permission: MissingEnum | bool | None = MISSING,
default_permission: bool | MissingEnum = MISSING,
type: ATYPE | MissingEnum = MISSING,
):
data = remove_undefined(
name=name,
Expand Down Expand Up @@ -148,14 +148,14 @@ async def create_guild_application_command(
application_id: Snowflake,
guild_id: Snowflake,
name: str,
name_localizations: dict[str, str] | UndefinedType = UNDEFINED,
description: str | UndefinedType = UNDEFINED,
description_localizations: dict[str, str] | UndefinedType = UNDEFINED,
options: list[ApplicationCommandOption] | UndefinedType = UNDEFINED,
default_member_permissions: str | None | UndefinedType = UNDEFINED,
dm_permission: UndefinedType | bool | None = UNDEFINED,
default_permission: bool | UndefinedType = UNDEFINED,
type: ATYPE | UndefinedType = UNDEFINED,
name_localizations: dict[str, str] | MissingEnum = MISSING,
description: str | MissingEnum = MISSING,
description_localizations: dict[str, str] | MissingEnum = MISSING,
options: list[ApplicationCommandOption] | MissingEnum = MISSING,
default_member_permissions: str | None | MissingEnum = MISSING,
dm_permission: MissingEnum | bool | None = MISSING,
default_permission: bool | MissingEnum = MISSING,
type: ATYPE | MissingEnum = MISSING,
):
data = remove_undefined(
name=name,
Expand Down Expand Up @@ -184,15 +184,15 @@ async def edit_guild_application_command(
application_id: Snowflake,
command_id: Snowflake,
guild_id: Snowflake,
name: str | UndefinedType = UNDEFINED,
name_localizations: dict[str, str] | UndefinedType = UNDEFINED,
description: str | UndefinedType = UNDEFINED,
description_localizations: dict[str, str] | UndefinedType = UNDEFINED,
options: list[ApplicationCommandOption] | UndefinedType = UNDEFINED,
default_member_permissions: str | None | UndefinedType = UNDEFINED,
dm_permission: UndefinedType | bool | None = UNDEFINED,
default_permission: bool | UndefinedType = UNDEFINED,
type: ATYPE | UndefinedType = UNDEFINED,
name: str | MissingEnum = MISSING,
name_localizations: dict[str, str] | MissingEnum = MISSING,
description: str | MissingEnum = MISSING,
description_localizations: dict[str, str] | MissingEnum = MISSING,
options: list[ApplicationCommandOption] | MissingEnum = MISSING,
default_member_permissions: str | None | MissingEnum = MISSING,
dm_permission: MissingEnum | bool | None = MISSING,
default_permission: bool | MissingEnum = MISSING,
type: ATYPE | MissingEnum = MISSING,
):
data = remove_undefined(
name=name,
Expand Down
12 changes: 6 additions & 6 deletions pycord/api/routers/audit_logs.py
Expand Up @@ -20,7 +20,7 @@
# SOFTWARE
from ...snowflake import Snowflake
from ...types import AUDIT_LOG_EVENT_TYPE, AuditLog
from ...undefined import UNDEFINED, UndefinedType
from ...missing import MISSING, MissingEnum
from ...utils import remove_undefined
from ..route import Route
from .base import BaseRouter
Expand All @@ -31,11 +31,11 @@ async def get_guild_audit_log(
self,
guild_id: Snowflake,
*,
user_id: Snowflake | UndefinedType = UNDEFINED,
action_type: AUDIT_LOG_EVENT_TYPE | UndefinedType = UNDEFINED,
before: Snowflake | UndefinedType = UNDEFINED,
after: Snowflake | UndefinedType = UNDEFINED,
limit: int | UndefinedType = UNDEFINED,
user_id: Snowflake | MissingEnum = MISSING,
action_type: AUDIT_LOG_EVENT_TYPE | MissingEnum = MISSING,
before: Snowflake | MissingEnum = MISSING,
after: Snowflake | MissingEnum = MISSING,
limit: int | MissingEnum = MISSING,
) -> AuditLog:
params = {
'user_id': user_id,
Expand Down
24 changes: 12 additions & 12 deletions pycord/api/routers/auto_moderation.py
Expand Up @@ -26,7 +26,7 @@
AutoModerationRule,
AutoModerationTriggerMetadata,
)
from ...undefined import UNDEFINED, UndefinedType
from ...missing import MISSING, MissingEnum
from ...utils import remove_undefined
from ..route import Route
from .base import BaseRouter
Expand Down Expand Up @@ -66,10 +66,10 @@ async def create_auto_moderation_rule(
event_type: AUTO_MODERATION_EVENT_TYPES,
trigger_type: AUTO_MODERATION_TRIGGER_TYPES,
actions: list[AutoModerationAction],
trigger_metadata: AutoModerationTriggerMetadata | UndefinedType = UNDEFINED,
trigger_metadata: AutoModerationTriggerMetadata | MissingEnum = MISSING,
enabled: bool = False,
exempt_roles: list[Snowflake] | UndefinedType = UNDEFINED,
exempt_channels: list[Snowflake] | UndefinedType = UNDEFINED,
exempt_roles: list[Snowflake] | MissingEnum = MISSING,
exempt_channels: list[Snowflake] | MissingEnum = MISSING,
reason: str | None = None,
) -> AutoModerationRule:
data = {
Expand Down Expand Up @@ -97,15 +97,15 @@ async def modify_auto_moderation_rule(
guild_id: Snowflake,
rule_id: Snowflake,
*,
name: str | UndefinedType = UNDEFINED,
event_type: AUTO_MODERATION_EVENT_TYPES | UndefinedType = UNDEFINED,
actions: list[AutoModerationAction] | UndefinedType = UNDEFINED,
name: str | MissingEnum = MISSING,
event_type: AUTO_MODERATION_EVENT_TYPES | MissingEnum = MISSING,
actions: list[AutoModerationAction] | MissingEnum = MISSING,
trigger_metadata: AutoModerationTriggerMetadata
| UndefinedType
| None = UNDEFINED,
enabled: bool | UndefinedType = UNDEFINED,
exempt_roles: list[Snowflake] | UndefinedType = UNDEFINED,
exempt_channels: list[Snowflake] | UndefinedType = UNDEFINED,
| MissingEnum
| None = MISSING,
enabled: bool | MissingEnum = MISSING,
exempt_roles: list[Snowflake] | MissingEnum = MISSING,
exempt_channels: list[Snowflake] | MissingEnum = MISSING,
reason: str | None = None,
) -> AutoModerationRule:
data = {
Expand Down

0 comments on commit 086a2a3

Please sign in to comment.