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

Closed
danwerner opened this Issue Mar 15, 2013 · 3 comments

Projects

None yet

2 participants

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.

Member
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.

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

Member
jayd3e commented Mar 18, 2013

Good catch, will change that.

@mcdonc mcdonc closed this in 2909ea8 Aug 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment