11"""StagYY par file handling."""
22
3+ from __future__ import annotations
34from copy import deepcopy
5+ import typing
46
57import f90nml
68
79from .config import CONFIG_DIR
810from .error import NoParFileError
911
12+ if typing .TYPE_CHECKING :
13+ from pathlib import Path
14+ from f90nml .namelist import Namelist
15+
1016PAR_DFLT_FILE = CONFIG_DIR / 'par'
1117PAR_DEFAULT = f90nml .namelist .Namelist ({
1218 'switches' : {
620626})
621627
622628
623- def _enrich_with_par (par_nml , par_file ):
629+ def _enrich_with_par (par_nml : Namelist , par_file : Path ):
624630 """Enrich a par namelist with the content of a file."""
625631 par_new = f90nml .read (str (par_file ))
626632 for section , content in par_new .items ():
@@ -634,7 +640,7 @@ def _enrich_with_par(par_nml, par_file):
634640 par_nml [section ].update (content )
635641
636642
637- def readpar (par_file , root ) :
643+ def readpar (par_file : Path , root : Path ) -> Namelist :
638644 """Read StagYY par file.
639645
640646 The namelist is populated in chronological order with:
@@ -646,13 +652,12 @@ def readpar(par_file, root):
646652 - ``parameters.dat`` if it can be found in the StagYY output directories.
647653
648654 Args:
649- par_file (:class:`pathlib.Path`): path of par file.
650- root (:class:`pathlib.Path`): path on which other paths are rooted.
651- This is usually par.parent.
655+ par_file: path of par file.
656+ root: path on which other paths are rooted. This is usually par.parent.
652657 Returns:
653- :class:`f90nml.namelist.Namelist`: case insensitive dict of dict of
654- values with first key being the namelist and second key the variables'
655- name .
658+ A :class:`f90nml.namelist.Namelist`. It is a case-insensitive dict of
659+ dict of values with first key being the namelist and second key the
660+ names of variables .
656661 """
657662 par_nml = deepcopy (PAR_DEFAULT )
658663
0 commit comments