Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions asdf/_asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ def __getitem__(self, key):
def __setitem__(self, key, value):
self.tree[key] = value

def __delitem__(self, key):
del self.tree[key]

def __contains__(self, item):
return item in self.tree

Expand Down
7 changes: 7 additions & 0 deletions asdf/_tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def test_top_level_tree(small_tree):
ff2["tree"] = small_tree
assert_tree_match(ff2.tree["tree"], ff2["tree"])

ff3 = asdf.AsdfFile(tree)
assert "tree" in ff3
del ff3["tree"]
assert "tree" not in ff3
with pytest.raises(KeyError):
_ = ff3["tree"]


def test_top_level_keys(small_tree):
tree = {"tree": small_tree}
Expand Down
1 change: 1 addition & 0 deletions changes/2008.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added ``__delitem__`` method to `AsdfFile`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat, I never thought to link to automodapi in the changelog, that's really useful
Image

Loading