jazzband / jsonmodels

jsonmodels is library to make it easier for you to deal with structures that are converted to, or read from JSON.
http://jsonmodels.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
334 stars 51 forks source link

ListField `items_types` parameter should be required #96

Open avrahamshukron opened 6 years ago

avrahamshukron commented 6 years ago

Right now this parameter has a None default value, which means that the actual value will be an empty tuple.

This creates inconsistent behavior:

class Foo(Base):
    l = ListField()  # Look ma, no `items_types`!

f = Foo()
f.l.append("a")  # works

# But look at this:
f = Foo(l=["a"])
Traceback (most recent call last):
 ...
ValidationError: Cannot decide which type to choose from "".

Inconsistency: Validation during __init__ is not the same as when using append.