summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sphinx/domains/__init__.py15
-rw-r--r--sphinx/domains/python.py23
-rw-r--r--sphinx/events.py8
-rw-r--r--sphinx/ext/autosummary/generate.py9
-rw-r--r--sphinx/transforms/post_transforms/code.py7
-rw-r--r--sphinx/util/images.py8
6 files changed, 41 insertions, 29 deletions
diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py
index f1d8523d4..e333af8ed 100644
--- a/sphinx/domains/__init__.py
+++ b/sphinx/domains/__init__.py
@@ -54,13 +54,14 @@ class ObjType:
self.attrs.update(attrs)
-IndexEntry = NamedTuple('IndexEntry', [('name', str),
- ('subtype', int),
- ('docname', str),
- ('anchor', str),
- ('extra', str),
- ('qualifier', str),
- ('descr', str)])
+class IndexEntry(NamedTuple):
+ name: str
+ subtype: int
+ docname: str
+ anchor: str
+ extra: str
+ qualifier: str
+ descr: str
class Index:
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index a5989bf7e..ba07b8847 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -63,15 +63,20 @@ pairindextypes = {
'builtin': _('built-in function'),
}
-ObjectEntry = NamedTuple('ObjectEntry', [('docname', str),
- ('node_id', str),
- ('objtype', str),
- ('canonical', bool)])
-ModuleEntry = NamedTuple('ModuleEntry', [('docname', str),
- ('node_id', str),
- ('synopsis', str),
- ('platform', str),
- ('deprecated', bool)])
+
+class ObjectEntry(NamedTuple):
+ docname: str
+ node_id: str
+ objtype: str
+ canonical: bool
+
+
+class ModuleEntry(NamedTuple):
+ docname: str
+ node_id: str
+ synopsis: str
+ platform: str
+ deprecated: bool
def type_to_xref(text: str) -> addnodes.pending_xref:
diff --git a/sphinx/events.py b/sphinx/events.py
index 3a3753895..9d7402554 100644
--- a/sphinx/events.py
+++ b/sphinx/events.py
@@ -25,9 +25,11 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
-EventListener = NamedTuple('EventListener', [('id', int),
- ('handler', Callable),
- ('priority', int)])
+
+class EventListener(NamedTuple):
+ id: int
+ handler: Callable
+ priority: int
# List of all known core events. Maps name to arguments description.
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py
index 91ef067a9..c45b90cdd 100644
--- a/sphinx/ext/autosummary/generate.py
+++ b/sphinx/ext/autosummary/generate.py
@@ -76,10 +76,11 @@ class DummyApplication:
pass
-AutosummaryEntry = NamedTuple('AutosummaryEntry', [('name', str),
- ('path', str),
- ('template', str),
- ('recursive', bool)])
+class AutosummaryEntry(NamedTuple):
+ name: str
+ path: str
+ template: str
+ recursive: bool
def setup_documenters(app: Any) -> None:
diff --git a/sphinx/transforms/post_transforms/code.py b/sphinx/transforms/post_transforms/code.py
index add35647b..f6ddb521f 100644
--- a/sphinx/transforms/post_transforms/code.py
+++ b/sphinx/transforms/post_transforms/code.py
@@ -21,9 +21,10 @@ from sphinx.ext import doctest
from sphinx.transforms import SphinxTransform
-HighlightSetting = NamedTuple('HighlightSetting', [('language', str),
- ('force', bool),
- ('lineno_threshold', int)])
+class HighlightSetting(NamedTuple):
+ language: str
+ force: bool
+ lineno_threshold: int
class HighlightLanguageTransform(SphinxTransform):
diff --git a/sphinx/util/images.py b/sphinx/util/images.py
index 0ddf64908..69bccb351 100644
--- a/sphinx/util/images.py
+++ b/sphinx/util/images.py
@@ -31,9 +31,11 @@ mime_suffixes = OrderedDict([
('.ai', 'application/illustrator'),
])
-DataURI = NamedTuple('DataURI', [('mimetype', str),
- ('charset', str),
- ('data', bytes)])
+
+class DataURI(NamedTuple):
+ mimetype: str
+ charset: str
+ data: bytes
def get_image_size(filename: str) -> Optional[Tuple[int, int]]: