jazzband / jazzband/jsonmodels

ListField `items_types` parameter should be required

Open
#96 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
343
Forks
50
PR merge metrics
No merged PRs in 30d

Description

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

This creates inconsistent behavior:
```python
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`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.