diff options
| -rw-r--r-- | bot/exts/info/doc/_cog.py | 18 | ||||
| -rw-r--r-- | bot/exts/info/doc/_doc_item.py | 16 | ||||
| -rw-r--r-- | bot/exts/info/doc/_redis_cache.py | 4 |
3 files changed, 19 insertions, 19 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index 271c83fff..bf27da4ab 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -4,7 +4,7 @@ import textwrap from collections import defaultdict from contextlib import suppress from types import SimpleNamespace -from typing import Literal, NamedTuple +from typing import Literal import aiohttp import discord @@ -21,6 +21,7 @@ from bot.utils.lock import SharedEvent, lock from bot.utils.messages import send_denial, wait_for_deletion from . import NAMESPACE, PRIORITY_PACKAGES, _batch_parser, doc_cache +from ._doc_item import DocItem from ._inventory_parser import InvalidHeaderError, InventoryDict, fetch_inventory log = get_logger(__name__) @@ -41,21 +42,6 @@ FETCH_RESCHEDULE_DELAY = SimpleNamespace(first=2, repeated=5) COMMAND_LOCK_SINGLETON = "inventory refresh" -class DocItem(NamedTuple): - """Holds inventory symbol information.""" - - package: str # Name of the package name the symbol is from - group: str # Interpshinx "role" of the symbol, for example `label` or `method` - base_url: str # Absolute path to to which the relative path resolves, same for all items with the same package - relative_url_path: str # Relative path to the page where the symbol is located - symbol_id: str # Fragment id used to locate the symbol on the page - - @property - def url(self) -> str: - """Return the absolute url to the symbol.""" - return self.base_url + self.relative_url_path - - class DocCog(commands.Cog): """A set of commands for querying & displaying documentation.""" diff --git a/bot/exts/info/doc/_doc_item.py b/bot/exts/info/doc/_doc_item.py new file mode 100644 index 000000000..a87b80efa --- /dev/null +++ b/bot/exts/info/doc/_doc_item.py @@ -0,0 +1,16 @@ +from typing import NamedTuple + + +class DocItem(NamedTuple): + """Holds inventory symbol information.""" + + package: str # Name of the package name the symbol is from + group: str # Interpshinx "role" of the symbol, for example `label` or `method` + base_url: str # Absolute path to to which the relative path resolves, same for all items with the same package + relative_url_path: str # Relative path to the page where the symbol is located + symbol_id: str # Fragment id used to locate the symbol on the page + + @property + def url(self) -> str: + """Return the absolute url to the symbol.""" + return self.base_url + self.relative_url_path diff --git a/bot/exts/info/doc/_redis_cache.py b/bot/exts/info/doc/_redis_cache.py index 72445897b..95003dab2 100644 --- a/bot/exts/info/doc/_redis_cache.py +++ b/bot/exts/info/doc/_redis_cache.py @@ -1,15 +1,13 @@ import datetime import fnmatch import time -from typing import TYPE_CHECKING from async_rediscache.types.base import RedisObject from bot.log import get_logger from bot.utils.lock import lock -if TYPE_CHECKING: - from ._cog import DocItem +from ._doc_item import DocItem WEEK_SECONDS = int(datetime.timedelta(weeks=1).total_seconds()) |