Skip to content

increase robustness of dataclass from dict; add missing electricity pricing update config - #3541

Merged
LKuemmel merged 3 commits into
openWB:masterfrom
LKuemmel:fix_electricity_pricing_update
Jun 15, 2026
Merged

LKuemmel merged 3 commits into
openWB:masterfrom
LKuemmel:fix_electricity_pricing_update

Conversation

@LKuemmel

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the configuration migration and dataclass construction utilities to better handle newly added electricity pricing provider config fields and dataclass defaults.

Changes:

  • Bump UpdateConfig.DATASTORE_VERSION to 129 and add an upgrade_datastore_129 migration to backfill missing tariff-provider config fields (e.g., update_hours, includes_grid_fee).
  • Improve dataclass_from_dict to correctly apply dataclass field defaults, including default_factory, when input dict keys are missing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/helpermodules/update_config.py Bumps datastore version and adds migration logic to populate missing electricity pricing provider configuration values.
packages/dataclass_utils/_dataclass_from_dict.py Enhances dict-to-dataclass conversion to honor dataclass defaults/default_factories when constructor args are missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/helpermodules/update_config.py Outdated
return {topic: provider}
return None
self._loop_all_received_topics(upgrade)
# self._append_datastore_version(129)
Comment on lines +38 to +44
if is_dataclass(cls):
dataclass_field = next((field for field in fields(cls) if field.name == argument_name), None)
if dataclass_field is not None:
if dataclass_field.default_factory is not MISSING:
value = dataclass_field.default_factory()
elif dataclass_field.default is not MISSING:
value = dataclass_field.default
@LKuemmel
LKuemmel merged commit dafda3b into openWB:master Jun 15, 2026
1 check passed
@LKuemmel
LKuemmel deleted the fix_electricity_pricing_update branch June 15, 2026 09:17
ndrsnhs pushed a commit to ndrsnhs/core that referenced this pull request Aug 24, 2026
…ricing update config (openWB#3541)

* increase robustness of dataclass from dict; add missing electricity pricing update config

* flake8, remove coment

* add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants