11from datetime import datetime
2- from typing import Any , Optional , Union
2+ from typing import Any
33
44import numpy as np
55import pint
1919
2020
2121# TODO move this to general utils
22- def str_to_unit (val_in : str ) -> Optional [ pint .Unit ] :
22+ def str_to_unit (val_in : str ) -> pint .Unit | None :
2323 """
2424 Convert string to pint.Unit
2525 """
@@ -33,7 +33,7 @@ def str_to_unit(val_in: str) -> Optional[pint.Unit]:
3333
3434
3535# TODO merge with str_to_scf_convergence
36- def str_to_energy_components (val_in : str ) -> dict [str , Union [ float , pint .Quantity ] ]:
36+ def str_to_energy_components (val_in : str ) -> dict [str , float | pint .Quantity ]:
3737 """
3838 Parse key, value pairs of energy components from string
3939 """
@@ -52,7 +52,7 @@ def str_to_energy_components(val_in: str) -> dict[str, Union[float, pint.Quantit
5252 return res
5353
5454
55- def str_to_scf_convergence (val_in : str ) -> dict [str , Union [ float , pint .Quantity ] ]:
55+ def str_to_scf_convergence (val_in : str ) -> dict [str , float | pint .Quantity ]:
5656 """
5757 Parse key, value pairs of scf convergence parameters.
5858 """
@@ -225,7 +225,7 @@ def str_to_gw_eigs(val_in: str) -> dict[str, np.ndarray]:
225225 return res
226226
227227
228- def str_to_gw_scf (val_in : str ) -> dict [str , Union [ float , pint .Quantity ] ]:
228+ def str_to_gw_scf (val_in : str ) -> dict [str , float | pint .Quantity ]:
229229 """
230230 Parse GW results
231231 """
@@ -240,7 +240,7 @@ def str_to_gw_scf(val_in: str) -> dict[str, Union[float, pint.Quantity]]:
240240 return data
241241
242242
243- def str_to_md_calculation_info (val_in : str ) -> dict [str , Union [ float , pint .Quantity ] ]:
243+ def str_to_md_calculation_info (val_in : str ) -> dict [str , float | pint .Quantity ]:
244244 """
245245 Parse molecular dynamics parameters
246246 """
@@ -264,7 +264,7 @@ def str_to_md_calculation_info(val_in: str) -> dict[str, Union[float, pint.Quant
264264 return res
265265
266266
267- def str_to_quantity (val_in : str ) -> Union [ float , pint .Quantity , None ] :
267+ def str_to_quantity (val_in : str ) -> float | pint .Quantity | None :
268268 val = val_in .split ()
269269 n = 2
270270 if len (val ) == 1 :
0 commit comments