From 97487d2d33058b5d524fa01e4c1778a867a7483b Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Mon, 1 Jul 2024 11:18:22 +0200 Subject: [PATCH] Hotfix imports utils --- .../schema_packages/utils/utils.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/nomad_simulations/schema_packages/utils/utils.py b/src/nomad_simulations/schema_packages/utils/utils.py index cbb0ce98..6c1ec42b 100644 --- a/src/nomad_simulations/schema_packages/utils/utils.py +++ b/src/nomad_simulations/schema_packages/utils/utils.py @@ -18,19 +18,22 @@ # from math import factorial -from typing import List, Optional +from typing import TYPE_CHECKING import numpy as np -from nomad.datamodel.data import ArchiveSection -from structlog.stdlib import BoundLogger + +if TYPE_CHECKING: + from typing import List, Optional + from nomad.datamodel.data import ArchiveSection + from structlog.stdlib import BoundLogger def get_sibling_section( - section: ArchiveSection, + section: 'ArchiveSection', sibling_section_name: str, - logger: BoundLogger, + logger: 'BoundLogger', index_sibling: int = 0, -) -> Optional[ArchiveSection]: +) -> 'Optional[ArchiveSection]': """ Gets the sibling section of a section by performing a seesaw move by going to the parent of the section and then going down to the sibling section. This is used, e.g., to get @@ -112,7 +115,7 @@ def degeneracy(self): ) -def is_not_representative(model_system, logger: BoundLogger): +def is_not_representative(model_system, logger: 'BoundLogger'): """ Checks if the given `ModelSystem` is not representative and logs a warning. @@ -133,8 +136,8 @@ def is_not_representative(model_system, logger: BoundLogger): # cannot define typing with `Variables` due to circular import issue def get_variables( - variables: Optional[List[ArchiveSection]], variable_cls: ArchiveSection -) -> List[ArchiveSection]: + variables: 'Optional[List[ArchiveSection]]', variable_cls: 'ArchiveSection' +) -> 'List[ArchiveSection]': """ Get the list of variables which are of type `variable_cls` and appear under `variables`. @@ -155,7 +158,7 @@ def get_variables( # TODO remove function in nomad.atomutils -def get_composition(children_names: List[str]) -> str: +def get_composition(children_names: 'List[str]') -> str: """ Generates a generalized "chemical formula" based on the provided list `children_names`, with the format X(m)Y(n) for children_names X and Y of quantities m and n, respectively.