Skip to content

Fix Choice rejecting set and frozenset choices - #198

Open
Sanjays2402 wants to merge 1 commit into
beetbox:mainfrom
Sanjays2402:fix/choice-set-support
Open

Fix Choice rejecting set and frozenset choices#198
Sanjays2402 wants to merge 1 commit into
beetbox:mainfrom
Sanjays2402:fix/choice-set-support

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #192.

Choice dispatches on the type of choices via singledispatchmethod and only registers abc.Sequence, dict and type, so a set/frozenset falls through to the base implementation and raises NotImplementedError — even though as_template(set()) returns a Choice, so sets are a supported way to build one.

Registered abc.Set for convert_choices and format_choices (and widened the choices annotations to match). The four new tests fail with NotImplementedError without the source change and pass with it; full suite 297 passed.

Choice dispatches on the type of `choices` via singledispatchmethod, but
only registered abc.Sequence, dict and type. Sets fall through to the base
implementation and raise NotImplementedError, even though as_template(set())
returns a Choice, so sets are a documented way to build one. This regressed
in v2.2.0.

Registered abc.Set for both convert_choices and format_choices, widened the
choices annotations to match, and added regression tests for set and
frozenset choices.

Closes beetbox#192
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.

Breaking Change in v2.2.0: Choice Template Objects No Longer Accept Iterables.

1 participant