Skip to content

Commit

Permalink
update docs for Converter.lazy attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed May 14, 2024
1 parent 32a4e42 commit 686dd94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions asdf/extension/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class Converter(abc.ABC):
and return a str, the selected tag (should be one of tags) or
`None` which will trigger the result of ``to_yaml_tree`` to be
used to look up the next converter for this object.
The ``lazy`` attribute is optional. If ``True`` asdf will
pass "lazy" objects to the converter. If ``False`` (or not
defined) asdf will convert all child objects before calling
`from_yaml_tree`.
"""

@classmethod
Expand Down
8 changes: 8 additions & 0 deletions docs/asdf/extending/converters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ when some logic is required to select the tag to assign to a ``to_yaml_tree`` re
`Converter.select_tag<Converter>` - an optional method that accepts a complex Python object and a list
candidate tags and returns the tag that should be used to serialize the object.

`Converter.lazy<Converter>` - a boolean attribute indicating if this converter accepts "lazy" objects
(those defined in `asdf.lazy_nodes`). This is mostly useful for container-like classes
(where the "lazy" objects can defer conversion of contained objects until they are accessed).
If a converter produces a generator lazy should be set to ``False`` as asdf will need
to generate nodes further out the branch to fully resolve the object returned from the
generator.


A simple example
================

Expand Down

0 comments on commit 686dd94

Please sign in to comment.