Skip to content

Commit c31a1a0

Browse files
committed
Remove pydantic setting use_enum_values=True
Reverting back to pydantic default behaviour. This implies at least that the queue_system member of QueueConfig is always of type QueueSystem, and never just a `str`, which breaks what the type hints say.
1 parent 4fb794e commit c31a1a0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/ert/config/queue_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class QueueOptions(
5151
BaseModelWithContextSupport,
5252
validate_assignment=True,
5353
extra="forbid",
54-
use_enum_values=True,
5554
validate_default=True,
5655
):
5756
name: QueueSystem

src/everest/config/everest_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
from argparse import ArgumentParser
44
from copy import copy
5+
from enum import StrEnum
56
from itertools import chain
67
from pathlib import Path
78
from sys import float_info
@@ -28,6 +29,8 @@
2829
from pydantic_core import ErrorDetails
2930
from pydantic_core.core_schema import ValidationInfo
3031
from ruamel.yaml import YAML, YAMLError
32+
from ruamel.yaml.nodes import ScalarNode
33+
from ruamel.yaml.representer import Representer
3134

3235
from ert.base_model_context import BaseModelWithContextSupport, use_runtime_plugins
3336
from ert.config import (
@@ -1098,6 +1101,12 @@ def write_dict_to_file(
10981101
yaml = YAML(typ="safe", pure=True) if safe_and_pure else YAML()
10991102
yaml.indent(mapping=2, sequence=4, offset=2)
11001103
yaml.preserve_quotes = True
1104+
1105+
def strenum_representer(dumper: Representer, data: StrEnum) -> ScalarNode:
1106+
return dumper.represent_str(data.value)
1107+
1108+
yaml.representer.add_multi_representer(StrEnum, strenum_representer)
1109+
11011110
yaml.default_flow_style = False
11021111
yaml.dump(config, output_file)
11031112

0 commit comments

Comments
 (0)