Skip to content

fix: prevent OneOf.options()from emitting phantom pairs#2897

Open
JaeHyuckSa wants to merge 1 commit intomarshmallow-code:devfrom
JaeHyuckSa:fix-oneof-options-2869
Open

fix: prevent OneOf.options()from emitting phantom pairs#2897
JaeHyuckSa wants to merge 1 commit intomarshmallow-code:devfrom
JaeHyuckSa:fix-oneof-options-2869

Conversation

@JaeHyuckSa
Copy link

@JaeHyuckSa JaeHyuckSa commented Feb 7, 2026

Description

Replaced it with zip bounded by the number of choices, added a warning when labels exceed choices, and included the related test coverage.

Related Issue

Fix: #2869

Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
Copy link
Member

@lafrech lafrech left a comment

Choose a reason for hiding this comment

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

Hi. Sorry about the delay. Looks good.

Just minor comments.

Thanks.

"Extra labels will be ignored in options().",
stacklevel=2,
)
except TypeError:
Copy link
Member

Choose a reason for hiding this comment

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

In which case is this exception raised?

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
oneof = validate.OneOf([1, 2], ["one", "two", "three"])
assert len(w) == 1
Copy link
Member

Choose a reason for hiding this comment

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

We might want to check the warning message, kinda like pytest.raises's match argument.

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.

OneOf.options() emits extra pairs when labels outnumber choices

2 participants