When building docs without any dependencies, autodoc will mock all the packages missing from the system. Because DTS makes use of a special enum library called aenum, autodoc fails to recognise enum inheriting it as such and raises exceptions as a consequence.
This change extends the already in-place mechanism for type checking that pretends that aenums are builtin enums to the API doc building process. Fixes: 039256daa8bf ("dts: add topology capability") Fixes: c89d00380603 ("dts: add NIC capability support") Signed-off-by: Luca Vizzarro <luca.vizza...@arm.com> Reviewed-by: Paul Szczepanek <paul.szczepa...@arm.com> --- dts/framework/remote_session/testpmd_shell.py | 3 ++- dts/framework/testbed_model/topology.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 8a45a5231b..1561862f46 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -20,10 +20,11 @@ from collections.abc import Callable, MutableSet from dataclasses import dataclass, field from enum import Flag, auto +from os import environ from pathlib import PurePath from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, ParamSpec, TypeAlias -if TYPE_CHECKING: +if TYPE_CHECKING or environ.get("DTS_DOC_BUILD"): from enum import Enum as NoAliasEnum else: from aenum import NoAliasEnum diff --git a/dts/framework/testbed_model/topology.py b/dts/framework/testbed_model/topology.py index 17b333e76a..3824804310 100644 --- a/dts/framework/testbed_model/topology.py +++ b/dts/framework/testbed_model/topology.py @@ -8,9 +8,10 @@ """ from dataclasses import dataclass +from os import environ from typing import TYPE_CHECKING, Iterable -if TYPE_CHECKING: +if TYPE_CHECKING or environ.get("DTS_DOC_BUILD"): from enum import Enum as NoAliasEnum else: from aenum import NoAliasEnum -- 2.43.0