diff options
| author | 2021-08-07 05:23:03 +0300 | |
|---|---|---|
| committer | 2021-08-31 13:08:51 -0700 | |
| commit | 745cd1d6d3d6227d2a1e82cf25611d76221c40cd (patch) | |
| tree | 6d653668fe1bbfd237b4c87890e0c67a36e2c7f5 /bot/exts/halloween | |
| parent | Merge pull request #835 from python-discord/discord-2.0 (diff) | |
Fix type annotations
Diffstat (limited to 'bot/exts/halloween')
| -rw-r--r-- | bot/exts/halloween/hacktober-issue-finder.py | 6 | ||||
| -rw-r--r-- | bot/exts/halloween/hacktoberstats.py | 14 | ||||
| -rw-r--r-- | bot/exts/halloween/halloween_facts.py | 3 | ||||
| -rw-r--r-- | bot/exts/halloween/spookyrating.py | 3 | ||||
| -rw-r--r-- | bot/exts/halloween/timeleft.py | 3 |
5 files changed, 13 insertions, 16 deletions
diff --git a/bot/exts/halloween/hacktober-issue-finder.py b/bot/exts/halloween/hacktober-issue-finder.py index 20a06770..e3053851 100644 --- a/bot/exts/halloween/hacktober-issue-finder.py +++ b/bot/exts/halloween/hacktober-issue-finder.py @@ -1,7 +1,7 @@ import datetime import logging import random -from typing import Dict, Optional +from typing import Optional import discord from discord.ext import commands @@ -49,7 +49,7 @@ class HacktoberIssues(commands.Cog): embed = self.format_embed(issue) await ctx.send(embed=embed) - async def get_issues(self, ctx: commands.Context, option: str) -> Optional[Dict]: + async def get_issues(self, ctx: commands.Context, option: str) -> Optional[dict]: """Get a list of the python issues with the label 'hacktoberfest' from the Github api.""" if option == "beginner": if (ctx.message.created_at - self.cache_timer_beginner).seconds <= 60: @@ -96,7 +96,7 @@ class HacktoberIssues(commands.Cog): return data @staticmethod - def format_embed(issue: Dict) -> discord.Embed: + def format_embed(issue: dict) -> discord.Embed: """Format the issue data into a embed.""" title = issue["title"] issue_url = issue["url"].replace("api.", "").replace("/repos/", "/") diff --git a/bot/exts/halloween/hacktoberstats.py b/bot/exts/halloween/hacktoberstats.py index 24106a5e..3661cf16 100644 --- a/bot/exts/halloween/hacktoberstats.py +++ b/bot/exts/halloween/hacktoberstats.py @@ -3,7 +3,7 @@ import random import re from collections import Counter from datetime import datetime, timedelta -from typing import List, Optional, Tuple, Union +from typing import Optional, Union from urllib.parse import quote_plus import discord @@ -139,7 +139,7 @@ class HacktoberStats(commands.Cog): else: await ctx.send(f"No valid Hacktoberfest PRs found for '{github_username}'") - async def build_embed(self, github_username: str, prs: List[dict]) -> discord.Embed: + async def build_embed(self, github_username: str, prs: list[dict]) -> discord.Embed: """Return a stats embed built from github_username's PRs.""" logging.info(f"Building Hacktoberfest embed for GitHub user: '{github_username}'") in_review, accepted = await self._categorize_prs(prs) @@ -185,7 +185,7 @@ class HacktoberStats(commands.Cog): logging.info(f"Hacktoberfest PR built for GitHub user '{github_username}'") return stats_embed - async def get_october_prs(self, github_username: str) -> Optional[List[dict]]: + async def get_october_prs(self, github_username: str) -> Optional[list[dict]]: """ Query GitHub's API for PRs created during the month of October by github_username. @@ -302,7 +302,7 @@ class HacktoberStats(commands.Cog): return await resp.json() @staticmethod - def _has_label(pr: dict, labels: Union[List[str], str]) -> bool: + def _has_label(pr: dict, labels: Union[list[str], str]) -> bool: """ Check if a PR has label 'labels'. @@ -368,7 +368,7 @@ class HacktoberStats(commands.Cog): exp = r"https?:\/\/api.github.com\/repos\/([/\-\_\.\w]+)" return re.findall(exp, in_url)[0] - async def _categorize_prs(self, prs: List[dict]) -> tuple: + async def _categorize_prs(self, prs: list[dict]) -> tuple: """ Categorize PRs into 'in_review' and 'accepted' and returns as a tuple. @@ -391,7 +391,7 @@ class HacktoberStats(commands.Cog): return in_review, accepted @staticmethod - def _build_prs_string(prs: List[tuple], user: str) -> str: + def _build_prs_string(prs: list[tuple], user: str) -> str: """ Builds a discord embed compatible string for a list of PRs. @@ -424,7 +424,7 @@ class HacktoberStats(commands.Cog): return "contributions" @staticmethod - def _author_mention_from_context(ctx: commands.Context) -> Tuple[str, str]: + def _author_mention_from_context(ctx: commands.Context) -> tuple[str, str]: """Return stringified Message author ID and mentionable string from commands.Context.""" author_id = str(ctx.author.id) author_mention = ctx.author.mention diff --git a/bot/exts/halloween/halloween_facts.py b/bot/exts/halloween/halloween_facts.py index 5ad8cc57..ba3b5d17 100644 --- a/bot/exts/halloween/halloween_facts.py +++ b/bot/exts/halloween/halloween_facts.py @@ -3,7 +3,6 @@ import logging import random from datetime import timedelta from pathlib import Path -from typing import Tuple import discord from discord.ext import commands @@ -32,7 +31,7 @@ FACTS = list(enumerate(FACTS)) class HalloweenFacts(commands.Cog): """A Cog for displaying interesting facts about Halloween.""" - def random_fact(self) -> Tuple[int, str]: + def random_fact(self) -> tuple[int, str]: """Return a random fact from the loaded facts.""" return random.choice(FACTS) diff --git a/bot/exts/halloween/spookyrating.py b/bot/exts/halloween/spookyrating.py index 105d2164..f566fac2 100644 --- a/bot/exts/halloween/spookyrating.py +++ b/bot/exts/halloween/spookyrating.py @@ -3,7 +3,6 @@ import json import logging import random from pathlib import Path -from typing import Dict import discord from discord.ext import commands @@ -13,7 +12,7 @@ from bot.constants import Colours log = logging.getLogger(__name__) -data: Dict[str, Dict[str, str]] = json.loads(Path("bot/resources/halloween/spooky_rating.json").read_text("utf8")) +data: dict[str, dict[str, str]] = json.loads(Path("bot/resources/halloween/spooky_rating.json").read_text("utf8")) SPOOKY_DATA = sorted((int(key), value) for key, value in data.items()) diff --git a/bot/exts/halloween/timeleft.py b/bot/exts/halloween/timeleft.py index e80025dc..55109599 100644 --- a/bot/exts/halloween/timeleft.py +++ b/bot/exts/halloween/timeleft.py @@ -1,6 +1,5 @@ import logging from datetime import datetime -from typing import Tuple from discord.ext import commands @@ -21,7 +20,7 @@ class TimeLeft(commands.Cog): return start <= now <= end @staticmethod - def load_date() -> Tuple[datetime, datetime, datetime]: + def load_date() -> tuple[datetime, datetime, datetime]: """Return of a tuple of the current time and the end and start times of the next October.""" now = datetime.utcnow() year = now.year |