Skip to content

Commit 8fad366

Browse files
jnsnowMarkus Armbruster
authored andcommitted
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 <[email protected]> Message-ID: <[email protected]> Acked-by: Markus Armbruster <[email protected]> Signed-off-by: Markus Armbruster <[email protected]>
1 parent cbb698a commit 8fad366

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

docs/sphinx/qapi_domain.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@
99

1010
from typing import (
1111
TYPE_CHECKING,
12-
AbstractSet,
13-
Any,
14-
Dict,
15-
Iterable,
1612
List,
1713
NamedTuple,
18-
Optional,
1914
Tuple,
20-
Union,
2115
cast,
2216
)
2317

@@ -34,7 +28,6 @@
3428
SpaceNode,
3529
)
3630
from sphinx import addnodes
37-
from sphinx.addnodes import desc_signature, pending_xref
3831
from sphinx.directives import ObjectDescription
3932
from sphinx.domains import (
4033
Domain,
@@ -49,13 +42,24 @@
4942

5043

5144
if TYPE_CHECKING:
45+
from typing import (
46+
AbstractSet,
47+
Any,
48+
Dict,
49+
Iterable,
50+
Optional,
51+
Union,
52+
)
53+
5254
from docutils.nodes import Element, Node
5355

56+
from sphinx.addnodes import desc_signature, pending_xref
5457
from sphinx.application import Sphinx
5558
from sphinx.builders import Builder
5659
from sphinx.environment import BuildEnvironment
5760
from sphinx.util.typing import OptionSpec
5861

62+
5963
logger = logging.getLogger(__name__)
6064

6165

0 commit comments

Comments
 (0)