Custom init silences duplicate arguments
Closed this issue · 1 comments
Following on from the example in #6, this currently works: s = State(7, path=1)
.
s.path
is 1
, but that's not obvious, and it would normally cause TypeError: __new__() got multiple values for argument 'path'
as it does if __init__
is not defined.
The solution to this could be making all the arguments in __new__
keyword only, then in __call__
converting positional arguments destined for it into keyword arguments. Removing *args
from __new__
means that duplicated positional arguments will not be silently passed back to __call__
and will instead raise the normal exception. Since __new__
is (normally) never called by the user directly, this would also be fully backwards compatible.
Fixed and tests updated to catch this.