Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Emit warning when user passes string instead of list to OneOf #2074

Open
lafrech opened this issue Nov 25, 2022 · 1 comment
Open

Emit warning when user passes string instead of list to OneOf #2074

lafrech opened this issue Nov 25, 2022 · 1 comment

Comments

@lafrech
Copy link
Member

lafrech commented Nov 25, 2022

I just got caught.

I wrote

    validate=validate.OneOf("one", "two")

instead of

    validate=validate.OneOf(["one", "two"])

"one" would pass because "one" in "one" is True.

It might save users trouble if we emitted a warning when a string is passed instead of a non-string iterable.

In practice, it only affects lists made of two elements (or one but users would use Equal), so no big deal.

@deckar01
Copy link
Member

deckar01 commented Dec 6, 2022

I suppose there could be users passing single character sets as a string intentionally. It wouldn't be too much trouble to wrap them a list() call to silence a warning though.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants