Closed ticosax closed 5 years ago
There are many situations where there is a difference between None
and a missing field. It's an important and useful distinction. While a philosophical argument could be made that they should be treated equally by an API, that is a design decision that cannot easily be reverted. I don't see a good reason right now to break compatibility.
Let's say you define some defaults on the signature of your constructor
class Model:
def __init__(self, foo='a',**kwargs):
...
With the current implementation, if parameter foo
is omitted by the user the model will always see None
instead of a
. This is contradict the expectations one would make. As a workaround we need to define the same default value also on the Resource
. Which might become out of sync if we forgot. Not nice and error prone.
Avoid transmitting
None
values when not necessaryConsider a nullable field, not required without default, it shouldn't be given as
None
if absent. This is per definition an optional field, and should stay out of list of given input values if user did so.This is useful to distinguish omitted fields from the ones given by users.