satisfy the type checker

This commit is contained in:
Zomatree
2022-03-23 22:00:03 +00:00
parent 8641f45400
commit 452f1f45bc
7 changed files with 48 additions and 13 deletions
+1 -1
View File
@@ -184,7 +184,7 @@ class TextChannel(Channel, Messageable, EditableChannel):
else:
self.icon = None
def _get_channel_id(self) -> str:
async def _get_channel_id(self) -> str:
return self.id
@property
+1 -1
View File
@@ -21,7 +21,7 @@ __all__ = (
@runtime_checkable
class ExtensionProtocol(Protocol):
@staticmethod
def setup(client: CommandsClient):
def setup(client: CommandsClient) -> None:
raise NotImplementedError
class CommandsMeta(type):
+4 -4
View File
@@ -93,7 +93,7 @@ class Command:
traceback.print_exception(type(error), error, error.__traceback__)
@staticmethod
def extract_type(t):
def extract_type(t: Any) -> Any:
if origin := get_origin(t):
if origin is Annotated:
return get_args(t)[1]
@@ -101,8 +101,8 @@ class Command:
return t
@classmethod
async def convert_argument(cls, arg: str, annotation: Any, context: Context):
if annotation is not inspect._empty:
async def convert_argument(cls, arg: str, annotation: Any, context: Context) -> Any:
if annotation is not inspect.Signature.empty:
if annotation is str: # no converting is needed - its already a string
return arg
@@ -128,7 +128,7 @@ class Command:
else:
raise InvalidLiteralArgument(arg)
else:
return await maybe_coroutine(cast(Callable, annotation), arg, context)
return await maybe_coroutine(cast(Callable[[Any, Context], Any], annotation), arg, context)
else:
return arg
+1 -1
View File
@@ -25,7 +25,7 @@ class StringView:
return self.temp
char = self.next_char()
temp = []
temp: list[str] = []
while char == " ":
char = self.next_char()
+1 -1
View File
@@ -60,7 +60,7 @@ class _VoiceChannelOptional(TypedDict, total=False):
default_permissions: int
role_permissions: int
class VoiceChannel(_NonceChannel, _TextChannelOptional, BaseChannel):
class VoiceChannel(_NonceChannel, _VoiceChannelOptional, BaseChannel):
server: str
name: str
description: str
+39 -4
View File
@@ -10,6 +10,10 @@ if TYPE_CHECKING:
from .member import Member, MemberID
from .server import Server
from .user import Status, User
from .role import Permission
from .file import File
from .category import Category
from .server import SystemMessagesConfig
__all__ = (
"BasePayload",
@@ -97,17 +101,33 @@ class ChannelStartTypingEventPayload(BasePayload):
ChannelDeleteTypingEventPayload = ChannelStartTypingEventPayload
class ServerUpdateEventPayloadData(TypedDict, total=False):
owner: str
name: str
description: str
icon: File
banner: File
default_permissions: Permission
nsfw: bool
system_messages: SystemMessagesConfig
categories: list[Category]
class ServerUpdateEventPayload(BasePayload):
id: str
data: dict
data: ServerUpdateEventPayloadData
clear: Literal["Icon", "Banner", "Description"]
class ServerDeleteEventPayload(BasePayload):
id: str
class ServerMemberUpdateEventPayloadData(TypedDict, total=False):
nickname: str
avatar: File
roles: list[str]
class ServerMemberUpdateEventPayload(BasePayload):
id: MemberID
data: dict
data: ServerMemberUpdateEventPayloadData
clear: Literal["Nickname", "Avatar"]
class ServerMemberJoinEventPayload(BasePayload):
@@ -116,19 +136,34 @@ class ServerMemberJoinEventPayload(BasePayload):
ServerMemberLeaveEventPayload = ServerMemberJoinEventPayload
class ServerRoleUpdateEventPayloadData(TypedDict, total=False):
name: str
colour: str
hoist: bool
rank: int
class ServerRoleUpdateEventPayload(BasePayload):
id: str
role_id: str
data: dict
data: ServerRoleUpdateEventPayloadData
clear: Literal["Color"]
class ServerRoleDeleteEventPayload(BasePayload):
id: str
role_id: str
UserUpdateEventPayloadData = TypedDict("UserUpdateEventPayloadData", {
"status": Status,
"profile.background": File,
"profile.content": str,
"avatar": File,
"online": bool
}, total=False)
class UserUpdateEventPayload(BasePayload):
id: str
data: dict
data: UserUpdateEventPayloadData
clear: Literal["ProfileContent", "ProfileBackground", "StatusText", "Avatar"]
class UserRelationshipEventPayload(BasePayload):
+1 -1
View File
@@ -82,7 +82,7 @@ class User(Messageable):
avatar = data.get("avatar")
self.original_avatar = Asset(avatar, state) if avatar else None
relations = []
relations: list[Relation] = []
for relation in data.get("relations", []):
user = state.get_user(relation["_id"])