@@ -9,15 +9,9 @@
from typing import (
TYPE_CHECKING,
- AbstractSet,
- Any,
- Dict,
- Iterable,
List,
NamedTuple,
- Optional,
Tuple,
- Union,
cast,
)
@@ -34,7 +28,6 @@
SpaceNode,
)
from sphinx import addnodes
-from sphinx.addnodes import desc_signature, pending_xref
from sphinx.directives import ObjectDescription
from sphinx.domains import (
Domain,
@@ -49,13 +42,24 @@
if TYPE_CHECKING:
+ from typing import (
+ AbstractSet,
+ Any,
+ Dict,
+ Iterable,
+ Optional,
+ Union,
+ )
+
from docutils.nodes import Element, Node
+ from sphinx.addnodes import desc_signature, pending_xref
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.environment import BuildEnvironment
from sphinx.util.typing import OptionSpec
+
logger = logging.getLogger(__name__)
When using the annotations feature, type hints do not need to be imported at runtime, only at type check time. Move type-check-only imports into a conditional to reduce the number of imports needed at runtime. Signed-off-by: John Snow <jsnow@redhat.com> --- docs/sphinx/qapi_domain.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)