summary refs log tree commit diff stats
path: root/docs/sphinx/qapi_domain.py
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2025-03-13 00:43:02 -0400
committerMarkus Armbruster <armbru@redhat.com>2025-03-14 07:31:56 +0100
commit8fad36626009ef51b52f4cdf08e29cc66284e41d (patch)
tree2b03297898d3a960b8ffa2c2e2e1bf3797bdbaf1 /docs/sphinx/qapi_domain.py
parentcbb698a2ba568f9746dee00ed59c442787103674 (diff)
downloadfocaccia-qemu-8fad36626009ef51b52f4cdf08e29cc66284e41d.tar.gz
focaccia-qemu-8fad36626009ef51b52f4cdf08e29cc66284e41d.zip
docs/qapi_domain: isolate TYPE_CHECKING imports
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>
Message-ID: <20250313044312.189276-2-jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to '')
-rw-r--r--docs/sphinx/qapi_domain.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/docs/sphinx/qapi_domain.py b/docs/sphinx/qapi_domain.py
index 7ff618d8cd..d52e7df7bc 100644
--- a/docs/sphinx/qapi_domain.py
+++ b/docs/sphinx/qapi_domain.py
@@ -9,15 +9,9 @@ from __future__ import annotations
 
 from typing import (
     TYPE_CHECKING,
-    AbstractSet,
-    Any,
-    Dict,
-    Iterable,
     List,
     NamedTuple,
-    Optional,
     Tuple,
-    Union,
     cast,
 )
 
@@ -34,7 +28,6 @@ from compat import (
     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 @@ from sphinx.util.nodes import make_id, make_refnode
 
 
 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__)