The size selector on the product page shows blank options that cannot be chosen. The select box is built from OneOf.options(), which pairs each choice with its label. When the label list is longer than the choice list, o…
The size selector on the product page shows blank options that cannot be chosen. The select box is built from OneOf.options(), which pairs each choice with its label. When the label list is longer than the choice list, options() keeps going and yields pairs with an empty value for the labels that are left over.
from marshmallow import validate
validator = validate.OneOf([1, 2, 3], labels=["one", "two", "three", "four", "five"])
list(validator.options())
[("1", "one"), ("2", "two"), ("3", "three")]
[("1", "one"), ("2", "two"), ("3", "three"), ("", "four"), ("", "five")]
OneOf([1, 2, 3], labels=["one"]) gives [("1", "one"), ("2", ""), ("3", "")].ContainsOnly shares options() and has the same problem.Adapted from marshmallow-code/marshmallow (MIT).
Visible test command
pytest testsThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
oneof-options-phantom-entries
Changes under src/ are evaluated.