55import logging
66from collections .abc import Sequence
77from pathlib import Path
8- from typing import Any , Optional , Union
8+ from typing import Any , Union
99
1010from abipy .abio .inputs import AbinitInput
1111from abipy .flowtk import events
@@ -89,7 +89,7 @@ class OutputDoc(BaseModel):
8989 """
9090
9191 structure : Union [Structure ] = Field (None , description = "The output structure object" )
92- trajectory : Optional [ Sequence [Union [Structure ]]] = Field (
92+ trajectory : Sequence [Union [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,47 @@ 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 )
198196 structure : Union [Structure ] = Field (
199197 None , description = "Final output atoms from the task"
200198 )
201- state : Optional [ TaskState ] = Field (None , description = "State of this task" )
202- event_report : Optional [ events .EventReport ] = Field (
199+ state : TaskState | None = Field (None , description = "State of this task" )
200+ event_report : events .EventReport | None = Field (
203201 None , description = "Event report of this abinit job."
204202 )
205- included_objects : Optional [ list [AbinitObject ]] = Field (
203+ included_objects : list [AbinitObject ] | None = Field (
206204 None , description = "List of Abinit objects included with this task document"
207205 )
208- abinit_objects : Optional [ dict [AbinitObject , Any ]] = Field (
206+ abinit_objects : dict [AbinitObject , Any ] | None = Field (
209207 None , description = "Abinit objects associated with this task"
210208 )
211- task_label : Optional [ str ] = Field (None , description = "A description of the task" )
212- tags : Optional [ list [str ]] = Field (
209+ task_label : str | None = Field (None , description = "A description of the task" )
210+ tags : list [str ] | None = Field (
213211 None , description = "Metadata tags for this task document"
214212 )
215- author : Optional [ str ] = Field (
213+ author : str | None = Field (
216214 None , description = "Author extracted from transformations"
217215 )
218- icsd_id : Optional [ str ] = Field (
216+ icsd_id : str | None = Field (
219217 None , description = "International crystal structure database id of the structure"
220218 )
221- calcs_reversed : Optional [ list [Calculation ]] = Field (
219+ calcs_reversed : list [Calculation ] | None = Field (
222220 None , description = "The inputs and outputs for all Abinit runs in this task."
223221 )
224- transformations : Optional [ dict [str , Any ]] = Field (
222+ transformations : dict [str , Any ] | None = Field (
225223 None ,
226224 description = "Information on the structural transformations, parsed from a "
227225 "transformations.json file" ,
@@ -231,7 +229,7 @@ class AbinitTaskDoc(StructureMetadata):
231229 description = "Information on the custodian settings used to run this "
232230 "calculation, parsed from a custodian.json file" ,
233231 )
234- additional_json : Optional [ dict [str , Any ]] = Field (
232+ additional_json : dict [str , Any ] | None = Field (
235233 None , description = "Additional json loaded from the calculation directory"
236234 )
237235
0 commit comments