diff --git a/etc/environment.yml b/etc/environment.yml index 13597bb10d..9e1fc34b8a 100644 --- a/etc/environment.yml +++ b/etc/environment.yml @@ -40,7 +40,7 @@ dependencies: - pytest-dotenv - pytest-xdist - pyzmq>=25.1.2 - - syrupy + - syrupy<5.0.0 - virtualenv # optional diff --git a/flopy/mf6/utils/codegen/filters.py b/flopy/mf6/utils/codegen/filters.py index a2731c30d4..037a9d9f67 100644 --- a/flopy/mf6/utils/codegen/filters.py +++ b/flopy/mf6/utils/codegen/filters.py @@ -205,12 +205,12 @@ def type(var: dict) -> str: def children(var: dict) -> Optional[dict]: _type = var["type"] - items = var.get("items", None) # TODO: fix to use "item" or "items" + item = var.get("item", None) fields = var.get("fields", None) choices = var.get("choices", None) - if items: + if item: assert _type == "recarray" - return items + return {item["name"]: item} if fields: assert _type == "record" return fields diff --git a/flopy/mf6/utils/codegen/templates/macros.jinja b/flopy/mf6/utils/codegen/templates/macros.jinja index 29c8a17248..4468761538 100644 --- a/flopy/mf6/utils/codegen/templates/macros.jinja +++ b/flopy/mf6/utils/codegen/templates/macros.jinja @@ -16,9 +16,12 @@ {{ v.description|clean|math|wordwrap|indent(loop.depth * 4, first=true) }} {% endif %} {% if recurse and children is not none %} -{% if v.type == "list" and children|length == 1 and (children.values()|first).type in ["record", "union"] %} +{% if v.type == "recarray" and children|length == 1 and (children.values()|first).name == v.name and (children.values()|first).type in ["record", "keystring"] %} +{# For recarray with single record item of same name, show the record's fields directly #} {% set grandchildren = (children.values()|first)|children %} +{% if grandchildren %} {{ loop(grandchildren.values())|indent(loop.depth * 4, first=true) }} +{% endif %} {% else %} {{ loop(children.values())|indent(loop.depth * 4, first=true) }} {% endif %} diff --git a/pyproject.toml b/pyproject.toml index bf6b704a0b..be5c8da9ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ test = [ "pytest-dotenv", "pytest-xdist", "pyzmq >=25.1.2", - "syrupy", + "syrupy <5.0.0", "tomli", "tomli-w", "virtualenv"