Skip to content

Commit

Permalink
Typing and importing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorukyum committed Jan 13, 2022
1 parent 1336473 commit b1245cf
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 20 deletions.
6 changes: 2 additions & 4 deletions discord/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import inspect
import sys
import types
from typing import Any, Callable, Mapping, ClassVar, Dict, Generator, List, Optional, TYPE_CHECKING, Tuple, TypeVar, \
Type
from typing import Any, Callable, Mapping, ClassVar, Dict, Generator, List, Optional, Tuple, TypeVar, Type

import discord.utils
from . import errors
from .commands.core import _BaseCommand
from .commands import SlashCommand, UserCommand, MessageCommand, ApplicationCommand, SlashCommandGroup
from .commands.core import _BaseCommand, ApplicationCommand, ApplicationContext

__all__ = (
'CogMeta',
Expand Down
2 changes: 1 addition & 1 deletion discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def _match_option_param_names(self, params, options):

check_annotations = [
lambda o, a: o.input_type == SlashCommandOptionType.string and o.converter is not None, # pass on converters
lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o._raw_type], # union types
lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o._raw_type], # type: ignore (union types)
lambda o, a: self._is_typing_optional(a) and not o.required and o._raw_type in a.__args__, # optional
lambda o, a: inspect.isclass(a) and issubclass(a, o._raw_type) # 'normal' types
]
Expand Down
2 changes: 1 addition & 1 deletion discord/ext/commands/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import discord
from ...cog import Cog

from typing import Any, Callable, Generator, TYPE_CHECKING, TypeVar, Type, Union
from typing import Any, Callable, Generator, TYPE_CHECKING, List, TypeVar, Type, Union

from ...commands import ApplicationCommand

Expand Down
4 changes: 2 additions & 2 deletions discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ async def send(
ctx: Context,
target: Optional[discord.abc.Messageable] = None,
target_message: Optional[str] = None,
) -> Union[discord.Message]:
) -> discord.Message:
"""Sends a message with the paginated items.
Parameters
Expand All @@ -554,7 +554,7 @@ async def send(
Returns
--------
Union[:class:`~discord.Message`]
:class:`~discord.Message`
The message that was sent with the paginator.
"""
if not isinstance(ctx, Context):
Expand Down
2 changes: 1 addition & 1 deletion discord/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

from typing import Any, Callable, ClassVar, Dict, Generic, Iterator, List, Optional, Tuple, Type, TypeVar, overload
from typing import Any, Callable, ClassVar, Dict, Iterator, List, Optional, Tuple, Type, TypeVar, overload

from .enums import UserFlags

Expand Down
1 change: 0 additions & 1 deletion discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from __future__ import annotations

import asyncio
import json
import logging
import sys
from typing import (
Expand Down
2 changes: 1 addition & 1 deletion discord/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from __future__ import annotations

import datetime
from typing import Any, Dict, Optional, TYPE_CHECKING, overload, Type, Tuple
from typing import Any, Dict, Optional, TYPE_CHECKING, Type, Tuple
from .utils import _get_as_snowflake, parse_time, MISSING
from .user import User
from .errors import InvalidArgument
Expand Down
2 changes: 1 addition & 1 deletion discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from . import utils
from .enums import try_enum, InteractionType, InteractionResponseType
from .errors import InteractionResponded, HTTPException, ClientException, InvalidArgument
from .errors import InteractionResponded, ClientException, InvalidArgument
from .channel import PartialMessageable, ChannelType
from .file import File
from .user import User
Expand Down
7 changes: 3 additions & 4 deletions discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@

from __future__ import annotations

import asyncio
import datetime
import re
import io
from os import PathLike
from typing import Dict, TYPE_CHECKING, Union, List, Optional, Any, Callable, Tuple, ClassVar, Optional, overload, TypeVar, Type
from typing import Dict, TYPE_CHECKING, Union, List, Optional, Any, Callable, Tuple, ClassVar, Optional, overload, TypeVar, Type, Sequence

from . import utils
from .reaction import Reaction
from .emoji import Emoji
from .partial_emoji import PartialEmoji
from .enums import MessageType, ChannelType, try_enum
from .errors import InvalidArgument, HTTPException
from .errors import InvalidArgument
from .components import _component_factory
from .embeds import Embed
from .member import Member
Expand Down Expand Up @@ -71,7 +70,7 @@
from .abc import GuildChannel, PartialMessageableChannel, MessageableChannel
from .components import Component
from .state import ConnectionState
from .channel import TextChannel, GroupChannel, DMChannel, PartialMessageable
from .channel import TextChannel
from .mentions import AllowedMentions
from .user import User
from .role import Role
Expand Down
2 changes: 1 addition & 1 deletion discord/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""

from __future__ import annotations
from typing import Any, Dict, List, Optional, TypeVar, Union, overload, TYPE_CHECKING
from typing import Any, Dict, List, Optional, TypeVar, Union, TYPE_CHECKING

from .permissions import Permissions
from .errors import InvalidArgument
Expand Down
1 change: 0 additions & 1 deletion discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import asyncio
from collections import deque, OrderedDict
import copy
import datetime
import itertools
import logging
from typing import Dict, Optional, TYPE_CHECKING, Union, Callable, Any, List, TypeVar, Coroutine, Sequence, Tuple, Deque
Expand Down
2 changes: 1 addition & 1 deletion discord/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from __future__ import annotations

from typing import Any, Optional, TYPE_CHECKING
from .utils import parse_time, _get_as_snowflake, _bytes_to_base64_data, MISSING
from .utils import parse_time, _bytes_to_base64_data, MISSING
from .enums import VoiceRegion
from .guild import Guild

Expand Down
2 changes: 1 addition & 1 deletion discord/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from .utils import snowflake_time, _get_as_snowflake, resolve_invite
from .user import BaseUser
from .activity import Activity, BaseActivity, Spotify, create_activity
from .activity import BaseActivity, Spotify, create_activity
from .invite import Invite
from .enums import Status, try_enum

Expand Down

0 comments on commit b1245cf

Please sign in to comment.