Skip to content

Commit bd76094

Browse files
committed
refactor(dfn): add reader attribute to Field
1 parent d169e61 commit bd76094

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

modflow_devtools/dfn.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ def _field_attr_sort_key(item) -> int:
105105
]
106106

107107

108+
Reader = Literal[
109+
"urword",
110+
"u1ddbl",
111+
"u2ddbl",
112+
"readarray",
113+
]
114+
115+
108116
_SCALAR_TYPES = FieldType.__args__[:4]
109117

110118

@@ -122,6 +130,7 @@ class Field(TypedDict):
122130
default: Any | None = None
123131
children: Optional["Fields"] = None
124132
description: str | None = None
133+
reader: Reader = "urword"
125134

126135

127136
class Ref(TypedDict):
@@ -300,6 +309,7 @@ def _load(field) -> Field:
300309
default = field.pop("default", None)
301310
default = _try_literal_eval(default) if _type != "string" else default
302311
description = field.pop("description", "")
312+
reader = field.pop("reader", "urword")
303313
ref = refs.get(_name, None)
304314

305315
# if the field is a foreign key, register it
@@ -336,6 +346,7 @@ def _item() -> Field:
336346
description=description.replace(
337347
"is the list of", "is the record of"
338348
),
349+
reader=reader,
339350
**field,
340351
)
341352

@@ -360,6 +371,7 @@ def _item() -> Field:
360371
description=description.replace(
361372
"is the list of", f"is the {item_type} of"
362373
),
374+
reader=reader,
363375
**field,
364376
)
365377

@@ -393,6 +405,7 @@ def _fields() -> Fields:
393405
block=block,
394406
description=description,
395407
default=default,
408+
reader=reader,
396409
**field,
397410
)
398411

@@ -433,6 +446,7 @@ def _fields() -> Fields:
433446
),
434447
default=None,
435448
ref=ref,
449+
reader=reader,
436450
**field,
437451
)
438452

0 commit comments

Comments
 (0)