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

SchemaNode constructor doesn't accept typ as a keyword argument #90

Closed
danwerner opened this issue Mar 15, 2013 · 3 comments · Fixed by #124
Closed

SchemaNode constructor doesn't accept typ as a keyword argument #90

danwerner opened this issue Mar 15, 2013 · 3 comments · Fixed by #124

Comments

@danwerner
Copy link

Constructing SchemaNodes as follows:

colander.SchemaNode(typ=colander.Integer)

Leads to a "NotImplementedError: SchemaNode construction without a typ argument ...". Ideally, the SchemaNode constructor would have code somewhat like this:

if arg:
    self.typ = arg[0]
    _add_node_children(self, arg[1:])
elif 'typ' in kw:
    self.typ = kw['typ']
else:
    self.typ = self.schema_type()

That would allow constructing SchemaNodes from dictionaries of arbitrary keyword arguments.

@jayd3e
Copy link
Contributor

jayd3e commented Mar 18, 2013

My only critique would be that instead of using 'typ' as the keyword, we should use 'type_'. As it is more clear.

@danwerner
Copy link
Author

Just noticed: In my example, instead of kw['typ'], it should probably be kw.pop('typ').

@jayd3e
Copy link
Contributor

jayd3e commented Mar 18, 2013

Good catch, will change that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants