Browse Source

Add return type hint for some functions

pull/8235/head
Harshal Laheri 3 years ago
committed by GitHub
parent
commit
20d3871290
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      discord/sticker.py
  2. 4
      discord/team.py
  3. 10
      discord/template.py
  4. 8
      discord/utils.py
  5. 2
      discord/voice_client.py
  6. 6
      discord/welcome_screen.py

2
discord/sticker.py

@ -198,7 +198,7 @@ class StickerItem(_StickerTag):
__slots__ = ('_state', 'name', 'id', 'format', 'url')
def __init__(self, *, state: ConnectionState, data: StickerItemPayload):
def __init__(self, *, state: ConnectionState, data: StickerItemPayload) -> None:
self._state: ConnectionState = state
self.name: str = data['name']
self.id: int = int(data['id'])

4
discord/team.py

@ -64,7 +64,7 @@ class Team:
__slots__ = ('_state', 'id', 'name', '_icon', 'owner_id', 'members')
def __init__(self, state: ConnectionState, data: TeamPayload):
def __init__(self, state: ConnectionState, data: TeamPayload) -> None:
self._state: ConnectionState = state
self.id: int = int(data['id'])
@ -130,7 +130,7 @@ class TeamMember(BaseUser):
__slots__ = ('team', 'membership_state', 'permissions')
def __init__(self, team: Team, state: ConnectionState, data: TeamMemberPayload):
def __init__(self, team: Team, state: ConnectionState, data: TeamMemberPayload) -> None:
self.team: Team = team
self.membership_state: TeamMembershipState = try_enum(TeamMembershipState, data['membership_state'])
self.permissions: List[str] = data['permissions']

10
discord/template.py

@ -49,7 +49,7 @@ class _FriendlyHttpAttributeErrorHelper:
class _PartialTemplateState:
def __init__(self, *, state):
def __init__(self, *, state) -> None:
self.__state = state
self.http = _FriendlyHttpAttributeErrorHelper()
@ -69,19 +69,19 @@ class _PartialTemplateState:
def member_cache_flags(self):
return self.__state.member_cache_flags
def store_emoji(self, guild, packet):
def store_emoji(self, guild, packet) -> None:
return None
def _get_voice_client(self, id):
def _get_voice_client(self, id) -> None:
return None
def _get_message(self, id):
def _get_message(self, id) -> None:
return None
def _get_guild(self, id):
return self.__state._get_guild(id)
async def query_members(self, **kwargs: Any):
async def query_members(self, **kwargs: Any) -> list:
return []
def __getattr__(self, attr):

8
discord/utils.py

@ -98,13 +98,13 @@ DISCORD_EPOCH = 1420070400000
class _MissingSentinel:
__slots__ = ()
def __eq__(self, other):
def __eq__(self, other) -> bool:
return False
def __bool__(self):
def __bool__(self) -> bool:
return False
def __hash__(self):
def __hash__(self) -> int:
return 0
def __repr__(self):
@ -115,7 +115,7 @@ MISSING: Any = _MissingSentinel()
class _cached_property:
def __init__(self, function):
def __init__(self, function) -> None:
self.function = function
self.__doc__ = getattr(function, '__doc__')

2
discord/voice_client.py

@ -233,7 +233,7 @@ class VoiceClient(VoiceProtocol):
secret_key: List[int]
ssrc: int
def __init__(self, client: Client, channel: abc.Connectable):
def __init__(self, client: Client, channel: abc.Connectable) -> None:
if not has_nacl:
raise RuntimeError("PyNaCl library needed in order to use voice")

6
discord/welcome_screen.py

@ -62,7 +62,9 @@ class WelcomeChannel:
The emoji used beside the channel description.
"""
def __init__(self, *, channel: Snowflake, description: str, emoji: Optional[Union[PartialEmoji, Emoji, str]] = None):
def __init__(
self, *, channel: Snowflake, description: str, emoji: Optional[Union[PartialEmoji, Emoji, str]] = None
) -> None:
self.channel = channel
self.description = description
self.emoji = emoji
@ -120,7 +122,7 @@ class WelcomeScreen:
The channels shown on the welcome screen.
"""
def __init__(self, *, data: WelcomeScreenPayload, guild: Guild):
def __init__(self, *, data: WelcomeScreenPayload, guild: Guild) -> None:
self._state = guild._state
self._guild = guild
self._store(data)

Loading…
Cancel
Save