diff options
author | Julian Berman <Julian@GrayVines.com> | 2013-05-20 22:47:47 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2013-05-20 22:47:47 -0400 |
commit | e48bc4ab34bd52ca41021ec48cd8b57dcd6af7a5 (patch) | |
tree | 47afcb1c25fb873418c3d7f572261fd840d354f9 | |
parent | b03996f0515212e5568c498db9d93767d241f000 (diff) | |
download | jsonschema-e48bc4ab34bd52ca41021ec48cd8b57dcd6af7a5.tar.gz |
Add some more docstrings to ErrorTree
-rw-r--r-- | docs/errors.rst | 2 | ||||
-rw-r--r-- | jsonschema/validators.py | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/docs/errors.rst b/docs/errors.rst index 7e0dde2..f168eeb 100644 --- a/docs/errors.rst +++ b/docs/errors.rst @@ -176,6 +176,8 @@ failed when validating a given instance, you probably will want to do so using .. autoclass:: ErrorTree :members: + :special-members: + :exclude-members: __dict__,__weakref__ Consider the following example: diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 69f05ea..1cb6c2e 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -417,8 +417,13 @@ class ErrorTree(object): self._instance = error.instance - def __contains__(self, k): - return k in self._contents + def __contains__(self, index): + """ + Check whether ``instance[index]`` has any errors. + + """ + + return index in self._contents def __getitem__(self, k): """ @@ -439,9 +444,19 @@ class ErrorTree(object): self._contents[k] = v def __iter__(self): + """ + Iterate (non-recursively) over the indices in the instance with errors. + + """ + return iter(self._contents) def __len__(self): + """ + Same as :attr:`total_errors`. + + """ + return self.total_errors def __repr__(self): |