diff options
| author | 2021-12-02 11:33:57 +0000 | |
|---|---|---|
| committer | 2021-12-02 11:33:57 +0000 | |
| commit | cb4114823b91056d9b552d3e75c3c8ca9e879da7 (patch) | |
| tree | 8fb1df9c03145cf0b7a0870f9fd79531410b5b3f | |
| parent | chore: Apply suggested changes (diff) | |
Make dataclasses hashable, and fix kwarg spelling error
| -rw-r--r-- | bot/exts/utilities/githubinfo.py | 22 | 
1 files changed, 6 insertions, 16 deletions
| diff --git a/bot/exts/utilities/githubinfo.py b/bot/exts/utilities/githubinfo.py index c9a65668..ee05497a 100644 --- a/bot/exts/utilities/githubinfo.py +++ b/bot/exts/utilities/githubinfo.py @@ -11,14 +11,7 @@ from aiohttp import ClientResponse  from discord.ext import commands  from bot.bot import Bot -from bot.constants import ( -    Categories, -    Colours, -    ERROR_REPLIES, -    Emojis, -    NEGATIVE_REPLIES, -    Tokens, -) +from bot.constants import Categories, Colours, ERROR_REPLIES, Emojis, NEGATIVE_REPLIES, Tokens  from bot.exts.core.extensions import invoke_help_command  log = logging.getLogger(__name__) @@ -41,7 +34,7 @@ WHITELISTED_CATEGORIES = (  )  CODE_BLOCK_RE = re.compile( -    r"^`([^`\n]+)`"  # Inline codeblock +    r"^`([^`\n]+)`"   # Inline codeblock      r"|```(.+?)```",  # Multiline codeblock      re.DOTALL | re.MULTILINE  ) @@ -56,7 +49,7 @@ AUTOMATIC_REGEX = re.compile(  ) -@dataclass +@dataclass(eq=True, frozen=True)  class FoundIssue:      """Dataclass representing an issue found by the regex.""" @@ -64,11 +57,8 @@ class FoundIssue:      repository: str      number: str -    def __hash__(self) -> int: -        return hash((self.organisation, self.repository, self.number)) - -@dataclass +@dataclass(eq=True, frozen=True)  class FetchError:      """Dataclass representing an error while fetching an issue.""" @@ -76,7 +66,7 @@ class FetchError:      message: str -@dataclass +@dataclass(eq=True, frozen=True)  class IssueState:      """Dataclass representing the state of an issue.""" @@ -237,7 +227,7 @@ class GithubInfo(commands.Cog):      async def fetch_data(self, url: str) -> tuple[dict[str], ClientResponse]:          """Retrieve data as a dictionary and the response in a tuple.""" -        async with self.bot.http_session.get(url, heades=REQUEST_HEADERS) as r: +        async with self.bot.http_session.get(url, headers=REQUEST_HEADERS) as r:              return await r.json(), r      @github_group.command(name="user", aliases=("userinfo",)) | 
