Skip to content

Fix return types, type hints, and unresolved references #3009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ async def runner():
if self._session:
await self._session.close()

# noinspection PyUnusedLocal
def stop_loop_on_completion(f):
loop.stop()

Expand Down Expand Up @@ -811,7 +812,7 @@ async def is_blocked(
*,
channel: discord.TextChannel = None,
send_message: bool = False,
) -> typing.Tuple[bool, str]:
) -> bool:

member = self.guild.get_member(author.id)
if member is None:
Expand Down Expand Up @@ -892,7 +893,9 @@ async def get_thread_cooldown(self, author: discord.Member):
return

@staticmethod
async def add_reaction(msg, reaction: discord.Reaction) -> bool:
async def add_reaction(
msg, reaction: typing.Union[discord.Emoji, discord.Reaction, discord.PartialEmoji, str]
) -> bool:
if reaction != "disable":
try:
await msg.add_reaction(reaction)
Expand Down
12 changes: 9 additions & 3 deletions core/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class GitHub:
def __init__(self, bot, access_token: str = "", username: str = "", **kwargs):
self.bot = bot
self.session = bot.session
self.headers: dict = None
self.headers: Optional[dict] = None
self.access_token = access_token
self.username = username
self.avatar_url: str = kwargs.pop("avatar_url", "")
Expand Down Expand Up @@ -319,7 +319,7 @@ async def get_config(self) -> dict:
async def update_config(self, data: dict):
return NotImplemented

async def edit_message(self, message_id: Union[int, str], new_content: str) -> None:
async def edit_message(self, message_id: Union[int, str], new_content: str):
return NotImplemented

async def append_log(
Expand Down Expand Up @@ -359,6 +359,12 @@ async def edit_note(self, message_id: Union[int, str], message: str):
def get_plugin_partition(self, cog):
return NotImplemented

async def update_repository(self) -> dict:
return NotImplemented

async def get_user_info(self) -> Optional[dict]:
return NotImplemented


class MongoDBClient(ApiClient):
def __init__(self, bot):
Expand Down Expand Up @@ -659,7 +665,7 @@ async def update_repository(self) -> dict:
"user": {"username": user.username, "avatar_url": user.avatar_url, "url": user.url,},
}

async def get_user_info(self) -> dict:
async def get_user_info(self) -> Optional[dict]:
try:
user = await GitHub.login(self.bot)
except InvalidConfigError:
Expand Down