Skip to content

feature: Adding Python type hints for input specifications #2298

@dannbuckley

Description

@dannbuckley

Is your feature request related to a problem? Please describe.
The documentation for the "type recarray" entries in the dfn specifications is sometimes hard to understand. These parameters might be a little easier to understand if there were type annotations in the __init__ definitions. This is sort of already done in the package docstring, but the docstring is written in MODFLOW descriptive types.

Describe the solution you'd like
Add an annotation line to the dfn specification to store Python type information, and modify the createpackages.py utility to add Python type annotations to the package __init__ definition.

Example dfn change (sim-tdis.dfn):

block perioddata
name perioddata
type recarray perlen nstp tsmult
+ annotation = tuple[tuple[float, int, float], ...]
reader urword
optional false
longname stress period time information
description
default_value ((1.0, 1, 1.0),)

Example __init__ change after updating packages: (mftdis.py):

def __init__(
    self,
    simulation,
    ...,
-   perioddata=((1.0, 1, 1.0),),
+   perioddata: tuple[tuple[float, int, float], ...] = ((1.0, 1, 1.0),),
    ...,
):
    ...

Additional context
Some examples:

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions