Skip to content

feat: allow invalid output fields to be dropped instead of raising#248

Merged
haneug merged 10 commits into
faccts:mainfrom
haneug:feature/pydantic-greedy
Jun 17, 2026
Merged

feat: allow invalid output fields to be dropped instead of raising#248
haneug merged 10 commits into
faccts:mainfrom
haneug:feature/pydantic-greedy

Conversation

@haneug

@haneug haneug commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Closes Issues

Closes None

Description

  • Adds an optional keyword strict=True to Output.__init__() and to Output.parse() which allows to drop the fields where Pydantic validation fail when it is set to False. This way we do not switch the current behavior but have the option for a less strict output generation.

Release Notes

Added

  • Output.parse(), Output.parse_property(), Output.parse_gbw(), and Output.__init__() now accept a strict parameter (default True). When set to False, output fields that fail Pydantic validation are silently set to None and a UserWarning is emitted instead of raising a ValidationError (feat: allow invalid output fields to be dropped instead of raising #248).

@haneug haneug self-assigned this Jun 2, 2026
@haneug haneug added enhancement New feature or request side output Concerning parsing ORCA output labels Jun 2, 2026
@haneug haneug marked this pull request as ready for review June 3, 2026 08:05
@haneug haneug requested a review from a team as a code owner June 3, 2026 08:05

@timmyte timmyte 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.

Thanks for adding this feature. That's a very good idea.

It would be great if you could generally document your code more extensively, as it does introduce new concepts, which are not trivial.

What is not clear to me: You are saying, that in non-strict mode invalid keys are set to None? But what if their default value is not None?

Comment thread src/opi/output/models/base/get_item.py Outdated
Comment thread src/opi/output/models/base/get_item.py
Comment thread src/opi/output/models/base/get_item.py
Comment thread src/opi/output/models/base/get_item.py
Comment thread src/opi/output/models/base/get_item.py Outdated
Comment thread src/opi/output/core.py
Comment thread src/opi/output/core.py Outdated
Comment thread src/opi/output/core.py Outdated
Comment thread src/opi/output/core.py Outdated
Comment thread tests/unit/test_output_partial_validation.py
haneug and others added 5 commits June 15, 2026 12:00
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
@haneug haneug requested a review from timmyte June 15, 2026 11:20
@haneug haneug merged commit f5ae3ff into faccts:main Jun 17, 2026
6 checks passed
@haneug haneug deleted the feature/pydantic-greedy branch June 17, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request side output Concerning parsing ORCA output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants