Ran isort over directory and added __all__

This commit is contained in:
ppotatoo
2021-09-02 15:16:25 -04:00
parent 9a53fb35d7
commit 553fbffa74
34 changed files with 201 additions and 52 deletions
+1
View File
@@ -12,6 +12,7 @@
import os
import sys
import sphinx_nameko_theme
sys.path.insert(0, os.path.abspath('..'))
+4 -1
View File
@@ -1,7 +1,10 @@
import revolt
import asyncio
import aiohttp
import revolt
class Client(revolt.Client):
async def on_message(self, message: revolt.Message):
if message.content == "hello":
+3 -2
View File
@@ -1,5 +1,6 @@
from .asset import Asset
from .channel import DMChannel, Channel, GroupDMChannel, SavedMessageChannel, VoiceChannel, TextChannel
from .channel import (Channel, DMChannel, GroupDMChannel, SavedMessageChannel,
TextChannel, VoiceChannel)
from .client import Client
from .embed import Embed
from .errors import HTTPError, RevoltError, ServerError
@@ -10,6 +11,6 @@ from .messageable import Messageable
from .permissions import Permissions
from .role import Role
from .server import Server
from .user import User, Status, Relation
from .user import Relation, Status, User
__version__ = (0, 0, 1)
+7 -3
View File
@@ -2,14 +2,18 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .errors import AutumnDisabled
from .enums import AssetType
from .errors import AutumnDisabled
if TYPE_CHECKING:
from .types import File as FilePayload
from .state import State
from io import IOBase
from .state import State
from .types import File as FilePayload
__all__ = ("Asset",)
class Asset:
"""Represents a file on revolt
+9 -2
View File
@@ -2,14 +2,21 @@ from __future__ import annotations
from typing import TYPE_CHECKING, cast
from .messageable import Messageable
from .enums import ChannelType
from .messageable import Messageable
if TYPE_CHECKING:
from .types import Channel as ChannelPayload, SavedMessages as SavedMessagesPayload, DMChannel as DMChannelPayload, Group as GroupDMChannelPayload, TextChannel as TextChannelPayload
from .state import State
from .types import Channel as ChannelPayload
from .types import DMChannel as DMChannelPayload
from .types import Group as GroupDMChannelPayload
from .types import SavedMessages as SavedMessagesPayload
from .types import TextChannel as TextChannelPayload
from .user import User
__all__ = ("Channel",)
class Channel:
"""Base class for all channels
+8 -4
View File
@@ -1,9 +1,10 @@
from __future__ import annotations
import asyncio
import aiohttp
from typing import Any, Callable, TypeVar, Coroutine, TYPE_CHECKING, Optional
import logging
from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional, TypeVar
import aiohttp
from .http import HttpClient
from .state import State
@@ -15,10 +16,13 @@ except ImportError:
import json
if TYPE_CHECKING:
from .channel import Channel
from .server import Server
from .types import ApiInfo
from .user import User
from .server import Server
from .channel import Channel
__all__ = ("Client",)
logger = logging.getLogger("revolt")
+3
View File
@@ -5,6 +5,9 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .types import Embed as EmbedPayload
__all__ = ("Embed",)
class Embed:
@classmethod
def from_dict(cls, data: EmbedPayload):
+8
View File
@@ -7,6 +7,14 @@ if TYPE_CHECKING:
else:
import aenum as enum
__all__ = (
"ChannelType",
"PresenceType",
"RelationshipType",
"AssetType"
)
class ChannelType(enum.Enum):
saved_message = "SavedMessage"
direct_message = "DirectMessage"
+8
View File
@@ -1,3 +1,11 @@
__all__ = (
"RevoltError",
"HTTPError",
"ServerError",
"FeatureDisabled",
"AutumnDisabled"
)
class RevoltError(Exception):
"Base exception for revolt"
+3 -2
View File
@@ -1,7 +1,8 @@
from typing import Optional, Union
import io
import os
from typing import Optional, Union
__all__ = ("File",)
class File:
"""Respresents a file about to be uploaded to revolt
+16 -4
View File
@@ -1,6 +1,8 @@
from __future__ import annotations
from typing import Any, Coroutine, Optional, TYPE_CHECKING, Literal, TypeVar, Union
from typing import (TYPE_CHECKING, Any, Coroutine, Literal, Optional, TypeVar,
Union)
import aiohttp
import ulid
@@ -14,10 +16,20 @@ except ImportError:
if TYPE_CHECKING:
import aiohttp
from .types import (
ApiInfo, Autumn as AutumnPayload, Message as MessagePayload, Embed as EmbedPayload, GetServerMembers, User as UserPayload,
Server, Member, UserProfile, ServerInvite, ServerBans, Channel, DMChannel, TextChannel, VoiceChannel, Role)
from .file import File
from .types import ApiInfo
from .types import Autumn as AutumnPayload
from .types import Channel, DMChannel
from .types import Embed as EmbedPayload
from .types import GetServerMembers, Member
from .types import Message as MessagePayload
from .types import Role, Server, ServerBans, ServerInvite, TextChannel
from .types import User as UserPayload
from .types import UserProfile, VoiceChannel
__all__ = ("HttpClient",)
T = TypeVar("T")
Request = Coroutine[Any, Any, T]
+4 -1
View File
@@ -5,9 +5,12 @@ from typing import TYPE_CHECKING
from .user import User
if TYPE_CHECKING:
from .server import Server
from .state import State
from .types import Member as MemberPayload
from .server import Server
__all__ = ("Member",)
def flattern_user(member: Member, user: User):
for attr in user.__flattern_attributes__:
+4 -1
View File
@@ -3,13 +3,16 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from .asset import Asset
from .embed import Embed
from .channel import Messageable
from .embed import Embed
if TYPE_CHECKING:
from .state import State
from .types import Message as MessagePayload
__all__ = ("Message",)
class Message:
"""Represents a message
+6 -4
View File
@@ -1,13 +1,15 @@
from __future__ import annotations
from typing import Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from .state import State
from .message import Message
from .embed import Embed
from .file import File
from .message import Message
from .state import State
__all__ = ("Messageable",)
class Messageable:
"""Base class for all channels that you can send messages in
+3
View File
@@ -5,6 +5,9 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .types import Permission as PermissionTuple
__all__ = ("Permissions",)
class Permissions:
def __init__(self, permission_tuple: PermissionTuple):
...
+3 -1
View File
@@ -2,11 +2,13 @@ from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .state import State
from .types import Role as RolePayload
__all__ = ("Role",)
class Role:
"""Represents a role
+6 -3
View File
@@ -2,14 +2,17 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Optional, cast
from .channel import Channel
from .permissions import Permissions
from .role import Role
from .channel import Channel
if TYPE_CHECKING:
from .types import Server as ServerPayload
from .state import State
from .member import Member
from .state import State
from .types import Server as ServerPayload
__all__ = ("Server",)
class Server:
"""Represents a server
+13 -5
View File
@@ -1,17 +1,25 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Optional
from collections import deque
from typing import TYPE_CHECKING, Optional
from .user import User
from .channel import Channel, channel_factory
from .server import Server
from .message import Message
from .member import Member
from .message import Message
from .server import Server
from .user import User
if TYPE_CHECKING:
from .http import HttpClient
from .types import ApiInfo, User as UserPayload, Channel as ChannelPayload, Server as ServerPayload, Message as MessagePayload, Member as MemberPayload
from .types import ApiInfo
from .types import Channel as ChannelPayload
from .types import Member as MemberPayload
from .types import Message as MessagePayload
from .types import Server as ServerPayload
from .types import User as UserPayload
__all__ = ("State",)
class State:
def __init__(self, http: HttpClient, api_info: ApiInfo, max_messages: int):
+3
View File
@@ -3,6 +3,9 @@ from typing import TYPE_CHECKING, TypedDict
if TYPE_CHECKING:
from .channel import Channel
__all__ = ("Category",)
class Category(TypedDict):
id: str
title: str
+11 -2
View File
@@ -1,10 +1,19 @@
from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict, Literal, Union
from typing import TYPE_CHECKING, Literal, TypedDict, Union
if TYPE_CHECKING:
from .message import Message
from .file import File
from .message import Message
__all__ = (
"DMChannel",
"Group",
"TextChannel",
"VoiceChannel",
"Channel"
)
class _NonceChannel(TypedDict, total=False):
nonce: str
+2
View File
@@ -2,5 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict
__all__ = ("Embed",)
class Embed(TypedDict):
pass # TODO
+3 -1
View File
@@ -1,6 +1,8 @@
from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict, Literal, Union
from typing import TYPE_CHECKING, Literal, TypedDict, Union
__all__ = ("File",)
class SizedMetadata(TypedDict):
type: Literal["Image", "Video"]
+9 -2
View File
@@ -5,10 +5,17 @@ from typing import TYPE_CHECKING, TypedDict
from .message import Message
if TYPE_CHECKING:
from .user import User
from .server import Server
from .channel import Channel
from .member import Member
from .server import Server
from .user import User
__all__ = (
"AuthenticatePayload",
"ReadyEventPayload",
"MessageEventPayload"
)
class BasePayload(TypedDict):
type: str
+9 -1
View File
@@ -3,8 +3,16 @@ from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict
if TYPE_CHECKING:
from .user import User
from .member import Member
from .user import User
__all__ = (
"VosoFeature",
"ApiInfo",
"Autumn",
"GetServerMembers"
)
class ApiFeature(TypedDict):
enabled: bool
+6
View File
@@ -1,5 +1,11 @@
from typing import Literal, TypedDict, Union
__all__ = (
"GroupInvite",
"ServerInvite",
"Invite"
)
class GroupInvite(TypedDict):
type: Literal["Group"]
_id: str
+3
View File
@@ -5,6 +5,9 @@ from typing import TYPE_CHECKING, TypedDict
if TYPE_CHECKING:
from .file import File
__all__ = ("Member",)
class _MemberOptional(TypedDict, total=False):
nickname: str
avatar: File
+7 -4
View File
@@ -3,8 +3,11 @@ from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict, Union
if TYPE_CHECKING:
from .file import File
from .embed import Embed
from .file import File
__all__ = ("Message",)
class UserAddContent(TypedDict):
id: str
@@ -24,7 +27,7 @@ class UserLeftContent(TypedDict):
class UserKickedContent(TypedDict):
id: str
class UserBanned(TypedDict):
class UserBannedContent(TypedDict):
id: str
class ChannelRenameContent(TypedDict):
@@ -34,7 +37,7 @@ class ChannelRenameContent(TypedDict):
class ChannelDescriptionChangeContent(TypedDict):
by: str
class ChannelIconChanged(TypedDict):
class ChannelIconChangeContent(TypedDict):
by: str
class _OptionalMessage(TypedDict):
@@ -45,4 +48,4 @@ class Message(_OptionalMessage):
_id: str
channel: str
author: str
content: Union[str, UserAddContent, UserRemoveContent, UserJoinedContent, UserLeftContent, UserKickedContent, UserBanned, ChannelRenameContent, ChannelDescriptionChangeContent, ChannelIconChanged]
content: Union[str, UserAddContent, UserRemoveContent, UserJoinedContent, UserLeftContent, UserKickedContent, UserBannedContent, ChannelRenameContent, ChannelDescriptionChangeContent, ChannelIconChangeContent]
+2
View File
@@ -2,6 +2,8 @@ from __future__ import annotations
from typing import TypedDict
__all__ = ("Role",)
Permission = tuple[int, int]
class _RoleOptional(TypedDict, total=False):
+9 -2
View File
@@ -3,10 +3,17 @@ from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict
if TYPE_CHECKING:
from .role import Role, Permission
from .file import File
from .category import Category
from .channel import Channel
from .file import File
from .role import Permission, Role
__all__ = (
"Server",
"BannedUser",
"Ban",
"ServerBans"
)
class SystemMessagesConfig(TypedDict, total=False):
user_joined: str
+9 -1
View File
@@ -1,10 +1,18 @@
from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict, Literal
from typing import TYPE_CHECKING, Literal, TypedDict
if TYPE_CHECKING:
from .file import File
__all__ = (
"Relation",
"UserBot",
"Status",
"User",
"UserProfile"
)
Relation = Literal["Blocked", "BlockedOther", "Friend", "Incoming", "None", "Outgoing", "User"]
class UserBot(TypedDict):
+6 -2
View File
@@ -3,11 +3,15 @@ from __future__ import annotations
from typing import TYPE_CHECKING, NamedTuple, Optional
from .asset import Asset
from .enums import RelationshipType, PresenceType
from .enums import PresenceType, RelationshipType
if TYPE_CHECKING:
from .state import State
from .types import User as UserPayload, UserRelation
from .types import User as UserPayload
from .types import UserRelation
__all__ = ("User",)
class Relation(NamedTuple):
"""A namedtuple representing a relation between the bot and a user"""
+2
View File
@@ -1,3 +1,5 @@
__all__ = ("Missing",)
class _Missing:
def __repr__(self):
return "<Missing>"
+9 -3
View File
@@ -1,8 +1,8 @@
from __future__ import annotations
from typing import Callable, TYPE_CHECKING, cast
import logging
import asyncio
import logging
from typing import TYPE_CHECKING, Callable, cast
from .types import Message as MessagePayload
@@ -19,8 +19,14 @@ except ImportError:
if TYPE_CHECKING:
import aiohttp
from .types import BasePayload, AuthenticatePayload, ReadyEventPayload, MessageEventPayload, Member as MemberPayload
from .state import State
from .types import AuthenticatePayload, BasePayload
from .types import Member as MemberPayload
from .types import MessageEventPayload, ReadyEventPayload
__all__ = ("WebsocketHandler",)
logger = logging.getLogger("revolt")
+2 -1
View File
@@ -1,6 +1,7 @@
from setuptools import setup, find_packages
import pathlib
from setuptools import find_packages, setup
here = pathlib.Path(__file__).parent.resolve()
long_description = (here / "README.md").read_text(encoding="utf-8")