3131from lib .vm import VM
3232from lib .xo import xo_cli , xo_object_exists
3333
34- from typing import TYPE_CHECKING , Literal , Optional , TypedDict , Union , cast , overload
34+ from typing import TYPE_CHECKING , Literal , TypedDict , cast , overload
3535
3636if TYPE_CHECKING :
3737 from lib .pool import Pool
@@ -52,7 +52,7 @@ def host_data(hostname_or_ip: str) -> dict[str, str]:
5252
5353class Host :
5454 xe_prefix = "host"
55- pool : Pool
55+ pool : " Pool"
5656
5757 # Data extraction is automatic, no conversion from str is done.
5858 BlockDeviceInfo = TypedDict ('BlockDeviceInfo' , {"name" : str ,
@@ -69,7 +69,7 @@ class Host:
6969 def __init__ (self , pool : Pool , hostname_or_ip : str ):
7070 self .pool = pool
7171 self .hostname_or_ip = hostname_or_ip
72- self .xo_srv_id : Optional [ str ] = None
72+ self .xo_srv_id : str | None = None
7373
7474 h_data = host_data (self .hostname_or_ip )
7575 self .user = h_data ['user' ]
@@ -82,7 +82,7 @@ def __init__(self, pool: Pool, hostname_or_ip: str):
8282 self .uuid = self .inventory ['INSTALLATION_UUID' ]
8383 self .xcp_version = version .parse (self .inventory ['PRODUCT_VERSION' ])
8484 self .xcp_version_short = f"{ self .xcp_version .major } .{ self .xcp_version .minor } "
85- self ._dom0 : Optional [ VM ] = None
85+ self ._dom0 : VM | None = None
8686
8787 self .rescan_block_devices_info ()
8888
@@ -117,7 +117,7 @@ def ssh(self, cmd: str, *, check: bool = True, simple_output: bool = True,
117117 def ssh (self , cmd : str , * , check : bool = True , simple_output : bool = True ,
118118 suppress_fingerprint_warnings : bool = True , background : bool = False , decode : bool = True ,
119119 multiplexing : bool = True ) \
120- -> Union [ str , bytes , commands .SSHResult , None ] :
120+ -> str | bytes | commands .SSHResult | None :
121121 ...
122122
123123 def ssh (self , cmd : str , * , check : bool = True , simple_output : bool = True ,
@@ -150,7 +150,7 @@ def xe(self, action: str, args: dict[str, str | bool | dict[str, str]] = {}, *,
150150
151151 def xe (self , action : str , args : dict [str , str | bool | dict [str , str ]] = {}, * , check : bool = True ,
152152 simple_output : bool = True , minimal : bool = False , force : bool = False ) \
153- -> Union [ str , commands .SSHResult ] :
153+ -> str | commands .SSHResult :
154154 maybe_param_minimal = '--minimal' if minimal else ''
155155 maybe_param_force = '--force' if force else ''
156156
@@ -176,16 +176,16 @@ def stringify(key: str, value: str | bool | dict[str, str]) -> str:
176176 return result
177177
178178 @overload
179- def param_get (self , param_name : str , key : Optional [ str ] = ...,
179+ def param_get (self , param_name : str , key : str | None = ...,
180180 accept_unknown_key : Literal [False ] = ...) -> str :
181181 ...
182182
183183 @overload
184- def param_get (self , param_name : str , key : Optional [ str ] = ...,
185- accept_unknown_key : Literal [True ] = ...) -> Optional [ str ] :
184+ def param_get (self , param_name : str , key : str | None = ...,
185+ accept_unknown_key : Literal [True ] = ...) -> str | None :
186186 ...
187187
188- def param_get (self , param_name : str , key : Optional [ str ] = None , accept_unknown_key : bool = False ) -> Optional [ str ] :
188+ def param_get (self , param_name : str , key : str | None = None , accept_unknown_key : bool = False ) -> str | None :
189189 return _param_get (self , self .xe_prefix , self .uuid ,
190190 param_name , key , accept_unknown_key )
191191
@@ -358,8 +358,8 @@ def cached_vm(self, uri: str, sr_uuid: str) -> VM | None:
358358 logging .info ("Could not find a VM in cache for %r" , uri )
359359 return None
360360
361- def import_vm (self , uri : str , sr_uuid : str | None = None , use_cache : bool = False ) -> "VM" :
362- vm = None
361+ def import_vm (self , uri : str , sr_uuid : str | None = None , use_cache : bool = False ) -> VM :
362+ vm : VM | None = None
363363 if use_cache :
364364 assert sr_uuid is not None
365365 if '://' in uri and uri .startswith ("clone" ):
@@ -772,7 +772,7 @@ def get_dom0_vm(self) -> VM:
772772 self ._dom0 = VM (self .get_dom0_uuid (), self )
773773 return self ._dom0
774774
775- def get_sr_from_vdi_uuid (self , vdi_uuid : str ) -> Optional [ SR ] :
775+ def get_sr_from_vdi_uuid (self , vdi_uuid : str ) -> SR | None :
776776 sr_uuid = self .xe ("vdi-param-get" , {
777777 "param-name" : "sr-uuid" ,
778778 "uuid" : vdi_uuid ,
0 commit comments