summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorAdam Turner <9087854+aa-turner@users.noreply.github.com>2023-03-17 17:39:44 +0000
committerAdam Turner <9087854+aa-turner@users.noreply.github.com>2023-03-17 17:43:23 +0000
commit3d2114214b512a6cce7eabbfd8d4fb3ac8c448f3 (patch)
tree90d5454ce8a6ea979c05783cce71254a4f050fd7 /sphinx/util
parentae9008b1282278ae9ab7e53fa0d87e1a7be19e12 (diff)
downloadsphinx-git-3d2114214b512a6cce7eabbfd8d4fb3ac8c448f3.tar.gz
Improve static typing in ``intersphinx`` et al
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/inventory.py6
-rw-r--r--sphinx/util/typing.py7
2 files changed, 9 insertions, 4 deletions
diff --git a/sphinx/util/inventory.py b/sphinx/util/inventory.py
index a879a17dd..123a86d25 100644
--- a/sphinx/util/inventory.py
+++ b/sphinx/util/inventory.py
@@ -7,7 +7,7 @@ import zlib
from typing import IO, TYPE_CHECKING, Callable, Iterator
from sphinx.util import logging
-from sphinx.util.typing import Inventory
+from sphinx.util.typing import Inventory, InventoryItem
BUFSIZE = 16 * 1024
logger = logging.getLogger(__name__)
@@ -133,8 +133,8 @@ class InventoryFile:
if location.endswith('$'):
location = location[:-1] + name
location = join(uri, location)
- invdata.setdefault(type, {})[name] = (projname, version,
- location, dispname)
+ inv_item: InventoryItem = projname, version, location, dispname
+ invdata.setdefault(type, {})[name] = inv_item
return invdata
@classmethod
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index 3f2acb822..d4e87ef1d 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -51,7 +51,12 @@ OptionSpec = Dict[str, Callable[[str], Any]]
TitleGetter = Callable[[nodes.Node], str]
# inventory data on memory
-InventoryItem = Tuple[str, str, str, str]
+InventoryItem = Tuple[
+ str, # project name
+ str, # project version
+ str, # URL
+ str, # display name
+]
Inventory = Dict[str, Dict[str, InventoryItem]]