Change Namespace to handle null values as Python does for None #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TestPositionalsNargsOptional
adapted fromtest_argparse.py
gives an error'AssertionError: {} deepEqual {"foo":null}'
A dozen other classes in the py test file give similar errors.
The problem is that the JS
Namespace
class treatsnull
differently than the pythonNone
.Python gives every
dest
at least aNone
value.The JS
Namespace
tries to treat anull
value as the same asundefined
.However, because sometimes values are set with
Namespace.set()
, and othertimes with ordinary object assignment, sometimes a null value appears in
a namespace.
These tests do pass if a modified deepEqual is used, one that ignores
differences between
{bar: null}
and{}
Python has a special
Namespace
class because its baseObject
class doesnot directly accept attributes. It also defines a nice display method.
The resulting class is essentially the same as the Javascript
object
.To better match the Python:
namespace.isset()
to use_.has()
instead of!!
(!!null
isfalse
)namespace.set()
_.extend()
alternative is not used.namespace.get()
is not used