12
12
from struct import pack , unpack
13
13
import subprocess
14
14
from sys import modules
15
- from typing import List , Union
15
+ from typing import List
16
16
17
17
from ansys .api .edb .v1 .arc_data_pb2_grpc import ArcDataServiceStub
18
18
from ansys .api .edb .v1 .board_bend_def_pb2_grpc import BoardBendDefServiceStub
@@ -233,7 +233,7 @@ def server_url(self) -> str:
233
233
return "{}:{}" .format (self .ip_address , self .port_num )
234
234
235
235
@property
236
- def server_executable (self ) -> Union [ str , None ] :
236
+ def server_executable (self ) -> str | None :
237
237
if self .is_launch ():
238
238
return which (cmd = "EDB_RPC_Server" , path = self .ansys_em_root )
239
239
else :
@@ -479,13 +479,13 @@ class StubType(Enum):
479
479
480
480
481
481
def attach_session (
482
- ip_address : Union [ str , None ] = None , port_num : int = 50051 , dump_traffic_log : bool = False
482
+ ip_address : str | None = None , port_num : int = 50051 , dump_traffic_log : bool = False
483
483
):
484
484
"""Attach a session to a port running the EDB API server.
485
485
486
486
Parameters
487
487
----------
488
- ip_address : Union[ str, None] , default: None
488
+ ip_address : str or None, default: None
489
489
IP address of the machine that is running the server. The default is ``None``,
490
490
in which case localhost is used.
491
491
port_num : int, default: 50051
@@ -498,9 +498,7 @@ def attach_session(
498
498
return MOD .current_session
499
499
500
500
501
- def launch_session (
502
- ansys_em_root : str , port_num : Union [int , None ] = None , dump_traffic_log : bool = False
503
- ):
501
+ def launch_session (ansys_em_root : str , port_num : int | None = None , dump_traffic_log : bool = False ):
504
502
r"""Launch a local session to an EDB API server.
505
503
506
504
The session must be manually disconnected after use by calling session.disconnect()
@@ -509,7 +507,7 @@ def launch_session(
509
507
----------
510
508
ansys_em_root : str
511
509
Directory where the ``EDB_RPC_Server.exe`` file is installed.
512
- port_num : Union[ int, None] , default: None
510
+ port_num : int or None, default: None
513
511
Port number to listen on. The default is ``None``, in which case a port in [50051, 60000]
514
512
is selected.
515
513
dump_traffic_log : bool, default: False
@@ -537,8 +535,8 @@ def launch_session(
537
535
@contextmanager
538
536
def session (
539
537
ansys_em_root : str ,
540
- port_num : Union [ int , None ] = None ,
541
- ip_address : Union [ str , None ] = None ,
538
+ port_num : int | None = None ,
539
+ ip_address : str | None = None ,
542
540
dump_traffic_log : bool = False ,
543
541
):
544
542
r"""Launch a local session to an EDB API server in a context manager.
@@ -547,10 +545,10 @@ def session(
547
545
----------
548
546
ansys_em_root : str
549
547
Directory where the ``EDB_RPC_Server.exe`` file is installed.
550
- port_num : Union[ int, None] , default: None
548
+ port_num : int or None, default: None
551
549
Port number to listen on. The default is ``None``, in which case a port in [50051, 60000]
552
550
is selected.
553
- ip_address : Union[ str, None] , default: None
551
+ ip_address : str or None, default: None
554
552
IP address where the server executable file is running. The default is ``None``, in which
555
553
case localhost is used.
556
554
@@ -619,7 +617,7 @@ def get_variable_server_stub() -> VariableServerServiceStub:
619
617
620
618
621
619
def _ensure_session (
622
- ansys_em_root : str , port_num : int , ip_address : Union [ str , None ] , dump_traffic_log : bool
620
+ ansys_em_root : str , port_num : int , ip_address : str | None , dump_traffic_log : bool
623
621
):
624
622
"""Check for a running local session and create one if it doesn't exist.
625
623
@@ -629,7 +627,7 @@ def _ensure_session(
629
627
Directory where the ``EDB_RPC_Server.exe`` file is installed.
630
628
port_num : int
631
629
Port number to listen on.
632
- ip_address : Union[ str, None]
630
+ ip_address : str or None
633
631
IP address where the server executable file is running.
634
632
dump_traffic_log : bool
635
633
Flag indicating if the network traffic log should be dumped when the session is disconnected.
0 commit comments