From d9a4212229c84c788ec791ee6dac704ef290e5d8 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Fri, 24 Jan 2025 19:32:49 -0500 Subject: [PATCH] fix(dfn): include missing attributes (#176) Only explicitly acknowledged variable attributes were parsed, we need them all --- modflow_devtools/dfn.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modflow_devtools/dfn.py b/modflow_devtools/dfn.py index cd31aea..ae8cfbd 100644 --- a/modflow_devtools/dfn.py +++ b/modflow_devtools/dfn.py @@ -229,20 +229,22 @@ def _load_variable(var: dict[str, Any]) -> Var: for a separate context will be given a reference to it. """ + var = var.copy() + # parse booleans from strings. everything else can # stay a string except default values, which we'll # try to parse as arbitrary literals below, and at # some point types, once we introduce type hinting var = {k: _try_parse_bool(v) for k, v in var.items()} - _name = var["name"] - _type = var.get("type", None) - shape = var.get("shape", None) + _name = var.pop("name") + _type = var.pop("type", None) + shape = var.pop("shape", None) shape = None if shape == "" else shape - block = var.get("block", None) - default = var.get("default", None) + block = var.pop("block", None) + default = var.pop("default", None) default = _try_literal_eval(default) if _type != "string" else default - description = var.get("description", "") + description = var.pop("description", "") ref = refs.get(_name, None) # if var is a foreign key, register it @@ -288,6 +290,7 @@ def _items() -> Vars: description=description.replace( "is the list of", "is the record of" ), + **var, ) } else: @@ -312,6 +315,7 @@ def _items() -> Vars: description=description.replace( "is the list of", f"is the {child_type} of" ), + **var, ) } @@ -345,6 +349,7 @@ def _fields() -> Vars: block=block, description=description, default=default, + **var, ) if _type.startswith("recarray"): @@ -385,6 +390,7 @@ def _fields() -> Vars: ), default=None, subpackage=ref, + **var, ) return var_