Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NamedTuples do not validate as tuples or named tuples #230

Closed
dangitall opened this issue Oct 9, 2016 · 1 comment
Closed

NamedTuples do not validate as tuples or named tuples #230

dangitall opened this issue Oct 9, 2016 · 1 comment

Comments

@dangitall
Copy link
Contributor

from collections import namedtuple

NT = namedtuple('NT', ['a', 'b'])

nt = NT(1, 2)
t = (1, 2)

Schema((int, int))(nt)    # => Invalid
Schema((int, int))(t)     # => Valid
Schema(NT(int, int))(nt)  # => Invalid
Schema(NT(int, int))(t)   # => Valid

Given that NT(1, 2) == (1, 2) => True I'd expect all of the above cases to return as valid.

@tusharmakkar08
Copy link
Collaborator

tusharmakkar08 commented Oct 9, 2016

@dangitall Thanks for reporting the issue.

Yeah, this seems like a bug in Voluptuous. Can you please submit a PR for the same?

dangitall added a commit to dangitall/voluptuous that referenced this issue Oct 9, 2016
namedtuples can't be initialized with a tuple. Detect that datatype and
initialize it with *args notation.

Resolves alecthomas#230
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

No branches or pull requests

2 participants