I think I've spotted an issue and I'm not sure if this is the intended behaviour, line ~2935 in model.py:
@classmethod
def __get_arg(cls, kwds, kwd):
"""Internal helper method to parse keywords that may be property names."""
alt_kwd = '_' + kwd
if alt_kwd in kwds:
return kwds.pop(alt_kwd)
if kwd in kwds:
obj = getattr(cls, kwd, None)
if not isinstance(obj, Property) or isinstance(obj, ModelKey):
return kwds.pop(kwd)
return None
more exactly: if not isinstance(obj, Property) or isinstance(obj, ModelKey):
Shouldn't this actually be: if not (isinstance(obj, Property) or isinstance(obj, ModelKey)): in order to pop out the potential keyword argument from the kwds dict? I think the logic of this is actually the following:
If the requested keyword argument name isn't by any chance an already existing property of the model (as Property or the special one ModelKey), only then retrieve & return the value (and pop the key out of kwds). Otherwise, we need to keep it in, because the value belongs to the property and it's not a parameter of the model initializer.
Or, for example in the key param case, I may be totally wrong, because ModelKey is subclass of Property and requesting it from the kwds should actually return it, but will fail in the first check, that's why there's the right side of the or which checks for this special property in order to return it (and pop it out from the properties), so the key can be post-processed and set inside the __init__ method, rather than being passed to the properties setting method furthermore.