From e4045ef62183f36f7f64215d3a35320cd9dfda17 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Mon, 27 Jan 2025 15:57:18 +0100 Subject: [PATCH] doc: add doctest for ConfigNamelist also add the last 2 missing `kw_only=True` to @dataclass --- src/sirocco/core/_tasks/shell_task.py | 2 +- src/sirocco/parsing/_yaml_data_models.py | 13 ++++++------- src/sirocco/pretty_print.py | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/sirocco/core/_tasks/shell_task.py b/src/sirocco/core/_tasks/shell_task.py index d163e597..cc7dbdf8 100644 --- a/src/sirocco/core/_tasks/shell_task.py +++ b/src/sirocco/core/_tasks/shell_task.py @@ -6,6 +6,6 @@ from sirocco.parsing._yaml_data_models import ConfigShellTaskSpecs -@dataclass +@dataclass(kw_only=True) class ShellTask(ConfigShellTaskSpecs, Task): pass diff --git a/src/sirocco/parsing/_yaml_data_models.py b/src/sirocco/parsing/_yaml_data_models.py index 9e603813..37809aa1 100644 --- a/src/sirocco/parsing/_yaml_data_models.py +++ b/src/sirocco/parsing/_yaml_data_models.py @@ -417,14 +417,13 @@ class ConfigNamelist: - specs is a dictionnary containing the specifications of parameters to change in the original namelist file - For example: - - ... python + Example: - ConfigNamelist(path="/some/path/to/icon.nml", - specs={"first_nml_block":{"first_param": first_value, - "second_param": second_value}, - "second_nml_block":{"third_param": third_value}}) + >>> path="/some/path/to/icon.nml" + >>> specs = {"first_nml_block": {"first_param": "a string value", + ... "second_param": 0}, + ... "second_nml_block": {"third_param": False}} + >>> config_nml = ConfigNamelist(path=path, specs=specs) """ path: Path diff --git a/src/sirocco/pretty_print.py b/src/sirocco/pretty_print.py index baaf7ac5..7e219573 100644 --- a/src/sirocco/pretty_print.py +++ b/src/sirocco/pretty_print.py @@ -8,7 +8,7 @@ from sirocco import core -@dataclasses.dataclass +@dataclasses.dataclass(kw_only=True) class PrettyPrinter: """ Pretty print unrolled workflow graph elements in a reproducible and human readable format.