55import logging
66from collections .abc import Sequence
77from pathlib import Path
8- from typing import Any , Optional , Union
8+ from typing import Any
99
1010from abipy .abio .inputs import AbinitInput
1111from abipy .flowtk import events
@@ -33,7 +33,7 @@ class InputDoc(BaseModel):
3333 The final pymatgen Structure of the final system
3434 """
3535
36- structure : Union [ Structure ] = Field (None , description = "The input structure object" )
36+ structure : Structure = Field (None , description = "The input structure object" )
3737 abinit_input : AbinitInput = Field (
3838 None , description = "AbinitInput used to perform calculation."
3939 )
@@ -88,8 +88,8 @@ class OutputDoc(BaseModel):
8888 Stress on the unit cell from the last calculation
8989 """
9090
91- structure : Union [ Structure ] = Field (None , description = "The output structure object" )
92- trajectory : Optional [ Sequence [Union [ Structure ]]] = Field (
91+ structure : Structure = Field (None , description = "The output structure object" )
92+ trajectory : Sequence [Structure ] | None = Field (
9393 None , description = "The trajectory of output structures"
9494 )
9595 energy : float = Field (
@@ -98,15 +98,15 @@ class OutputDoc(BaseModel):
9898 energy_per_atom : float = Field (
9999 None , description = "The final DFT energy per atom for the last calculation"
100100 )
101- bandgap : Optional [ float ] = Field (
101+ bandgap : float | None = Field (
102102 None , description = "The DFT bandgap for the last calculation"
103103 )
104- cbm : Optional [ float ] = Field (None , description = "CBM for this calculation" )
105- vbm : Optional [ float ] = Field (None , description = "VBM for this calculation" )
106- forces : Optional [ list [Vector3D ]] = Field (
104+ cbm : float | None = Field (None , description = "CBM for this calculation" )
105+ vbm : float | None = Field (None , description = "VBM for this calculation" )
106+ forces : list [Vector3D ] | None = Field (
107107 None , description = "Forces on atoms from the last calculation"
108108 )
109- stress : Optional [ Matrix3D ] = Field (
109+ stress : Matrix3D | None = Field (
110110 None , description = "Stress on the unit cell from the last calculation"
111111 )
112112
@@ -179,49 +179,45 @@ class AbinitTaskDoc(StructureMetadata):
179179 Additional json loaded from the calculation directory
180180 """
181181
182- dir_name : Optional [str ] = Field (
183- None , description = "The directory for this Abinit task"
184- )
185- last_updated : Optional [str ] = Field (
182+ dir_name : str | None = Field (None , description = "The directory for this Abinit task" )
183+ last_updated : str | None = Field (
186184 default_factory = datetime_str ,
187185 description = "Timestamp for when this task document was last updated" ,
188186 )
189- completed_at : Optional [ str ] = Field (
187+ completed_at : str | None = Field (
190188 None , description = "Timestamp for when this task was completed"
191189 )
192- input : Optional [ InputDoc ] = Field (
190+ input : InputDoc | None = Field (
193191 None , description = "The input to the first calculation"
194192 )
195- output : Optional [ OutputDoc ] = Field (
193+ output : OutputDoc | None = Field (
196194 None , description = "The output of the final calculation"
197195 )
198- structure : Union [Structure ] = Field (
199- None , description = "Final output atoms from the task"
200- )
201- state : Optional [TaskState ] = Field (None , description = "State of this task" )
202- event_report : Optional [events .EventReport ] = Field (
196+ structure : Structure = Field (None , description = "Final output atoms from the task" )
197+ state : TaskState | None = Field (None , description = "State of this task" )
198+ event_report : events .EventReport | None = Field (
203199 None , description = "Event report of this abinit job."
204200 )
205- included_objects : Optional [ list [AbinitObject ]] = Field (
201+ included_objects : list [AbinitObject ] | None = Field (
206202 None , description = "List of Abinit objects included with this task document"
207203 )
208- abinit_objects : Optional [ dict [AbinitObject , Any ]] = Field (
204+ abinit_objects : dict [AbinitObject , Any ] | None = Field (
209205 None , description = "Abinit objects associated with this task"
210206 )
211- task_label : Optional [ str ] = Field (None , description = "A description of the task" )
212- tags : Optional [ list [str ]] = Field (
207+ task_label : str | None = Field (None , description = "A description of the task" )
208+ tags : list [str ] | None = Field (
213209 None , description = "Metadata tags for this task document"
214210 )
215- author : Optional [ str ] = Field (
211+ author : str | None = Field (
216212 None , description = "Author extracted from transformations"
217213 )
218- icsd_id : Optional [ str ] = Field (
214+ icsd_id : str | None = Field (
219215 None , description = "International crystal structure database id of the structure"
220216 )
221- calcs_reversed : Optional [ list [Calculation ]] = Field (
217+ calcs_reversed : list [Calculation ] | None = Field (
222218 None , description = "The inputs and outputs for all Abinit runs in this task."
223219 )
224- transformations : Optional [ dict [str , Any ]] = Field (
220+ transformations : dict [str , Any ] | None = Field (
225221 None ,
226222 description = "Information on the structural transformations, parsed from a "
227223 "transformations.json file" ,
@@ -231,7 +227,7 @@ class AbinitTaskDoc(StructureMetadata):
231227 description = "Information on the custodian settings used to run this "
232228 "calculation, parsed from a custodian.json file" ,
233229 )
234- additional_json : Optional [ dict [str , Any ]] = Field (
230+ additional_json : dict [str , Any ] | None = Field (
235231 None , description = "Additional json loaded from the calculation directory"
236232 )
237233
0 commit comments