[PATCH v14 2/6] dts: replace the or operator in third party types
Juraj Linkeš
juraj.linkes at pantheon.tech
Tue Aug 6 13:17:52 CEST 2024
When the DTS dependencies are not installed when building DTS API
documentation, the or operator produces errors when used with types from
those libraries:
autodoc: failed to import module 'remote_session' from module
'framework'; the following exception was raised:
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) for |: 'Transport' and 'NoneType'
The third part type here is Transport from the paramiko library.
Signed-off-by: Juraj Linkeš <juraj.linkes at pantheon.tech>
---
dts/framework/remote_session/interactive_remote_session.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dts/framework/remote_session/interactive_remote_session.py b/dts/framework/remote_session/interactive_remote_session.py
index 97194e6af8..4605ee14b4 100644
--- a/dts/framework/remote_session/interactive_remote_session.py
+++ b/dts/framework/remote_session/interactive_remote_session.py
@@ -5,6 +5,7 @@
import socket
import traceback
+from typing import Union
from paramiko import AutoAddPolicy, SSHClient, Transport # type: ignore[import-untyped]
from paramiko.ssh_exception import ( # type: ignore[import-untyped]
@@ -52,7 +53,7 @@ class InteractiveRemoteSession:
session: SSHClient
_logger: DTSLogger
_node_config: NodeConfiguration
- _transport: Transport | None
+ _transport: Union[Transport, None]
def __init__(self, node_config: NodeConfiguration, logger: DTSLogger) -> None:
"""Connect to the node during initialization.
--
2.34.1
More information about the dev
mailing list