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

Comments

Projects
None yet
2 participants
@danwerner

danwerner commented Mar 15, 2013

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

This comment has been minimized.

Show comment
Hide comment
@jayd3e

jayd3e Mar 18, 2013

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@danwerner

danwerner Mar 18, 2013

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

danwerner commented Mar 18, 2013

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

@jayd3e

This comment has been minimized.

Show comment
Hide comment
@jayd3e

jayd3e Mar 18, 2013

Contributor

Good catch, will change that.

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