diff options
Diffstat (limited to 'sphinx/environment')
-rw-r--r-- | sphinx/environment/__init__.py | 12 | ||||
-rw-r--r-- | sphinx/environment/adapters/toctree.py | 2 | ||||
-rw-r--r-- | sphinx/environment/collectors/__init__.py | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 0483dcdf9..2914a78af 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -14,8 +14,8 @@ from collections import defaultdict from copy import copy from datetime import datetime from os import path -from typing import (TYPE_CHECKING, Any, Callable, Dict, Generator, Iterator, List, Set, Tuple, - Union) +from typing import (TYPE_CHECKING, Any, Callable, Dict, Generator, Iterator, List, Optional, + Set, Tuple, Union) from docutils import nodes from docutils.nodes import Node @@ -87,7 +87,7 @@ class BuildEnvironment: transformations to resolve links to them. """ - domains: Dict[str, Domain] = None + domains: Dict[str, Domain] # --------- ENVIRONMENT INITIALIZATION ------------------------------------- @@ -266,7 +266,7 @@ class BuildEnvironment: raise an exception if the user tries to use an environment with an incompatible versioning method. """ - condition: Union[bool, Callable] = None + condition: Union[bool, Callable] if callable(method): condition = method else: @@ -309,7 +309,7 @@ class BuildEnvironment: domain.merge_domaindata(docnames, other.domaindata[domainname]) self.events.emit('env-merge-info', self, docnames, other) - def path2doc(self, filename: str) -> str: + def path2doc(self, filename: str) -> Optional[str]: """Return the docname for the filename if the file is document. *filename* should be absolute or relative to the source directory. @@ -577,7 +577,7 @@ class BuildEnvironment: # allow custom references to be resolved self.events.emit('doctree-resolved', doctree, docname) - def collect_relations(self) -> Dict[str, List[str]]: + def collect_relations(self) -> Dict[str, List[Optional[str]]]: traversed = set() def traverse_toctree(parent: str, docname: str) -> Iterator[Tuple[str, str]]: diff --git a/sphinx/environment/adapters/toctree.py b/sphinx/environment/adapters/toctree.py index 6822c42c9..a62e951d7 100644 --- a/sphinx/environment/adapters/toctree.py +++ b/sphinx/environment/adapters/toctree.py @@ -313,7 +313,7 @@ class TocTree: return toc def get_toctree_for(self, docname: str, builder: "Builder", collapse: bool, - **kwargs: Any) -> Element: + **kwargs: Any) -> Optional[Element]: """Return the global TOC nodetree.""" doctree = self.env.get_doctree(self.env.config.root_doc) toctrees: List[Element] = [] diff --git a/sphinx/environment/collectors/__init__.py b/sphinx/environment/collectors/__init__.py index e27091018..f4020431f 100644 --- a/sphinx/environment/collectors/__init__.py +++ b/sphinx/environment/collectors/__init__.py @@ -8,7 +8,7 @@ :license: BSD, see LICENSE for details. """ -from typing import TYPE_CHECKING, Dict, List, Set +from typing import TYPE_CHECKING, Dict, List, Optional, Set from docutils import nodes @@ -27,7 +27,7 @@ class EnvironmentCollector: entries and toctrees, etc. """ - listener_ids: Dict[str, int] = None + listener_ids: Optional[Dict[str, int]] = None def enable(self, app: "Sphinx") -> None: assert self.listener_ids is None |