diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ff6c5c..71eb3bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,10 @@ ## 0.10.0 (unreleased) - BREAKING: - - Rename `shadow_attrs` argument to `forward_attrs` - - Enforce that the same object is not added multiple times to one parent + - Rename `shadow_attrs` argument to `forward_attrs`. + - Enforce that the same object is not added multiple times to one parent. - Rename `GenericNodeData` to `DictWrapper` and remove support for attribut access. -- tree.to_rdf() is now available for Tree (not only TypedTree) +- tree.to_rdf() is now available for Tree (not only TypedTree). - New method `node.up()` allows method chaining when adding nodes. - Passes more pyright 'basic' checks. diff --git a/docs/sphinx/ug_objects.rst b/docs/sphinx/ug_objects.rst index 1a9af65..a944f44 100644 --- a/docs/sphinx/ug_objects.rst +++ b/docs/sphinx/ug_objects.rst @@ -226,7 +226,7 @@ methods:: This means that two instances of DictWrapper with the same dict content will have different hash values. -.. info:: +.. note:: The `forward_attrs` feature is readonly, so you cannot modify the dict through the forwarded attributes. You need to access the dict directly for that. diff --git a/docs/sphinx/ug_search_and_navigate.rst b/docs/sphinx/ug_search_and_navigate.rst index f8d3962..e9c1e31 100644 --- a/docs/sphinx/ug_search_and_navigate.rst +++ b/docs/sphinx/ug_search_and_navigate.rst @@ -139,6 +139,8 @@ Different traversal methods are supported. :: # to materialize: res = list(node.iterator(add_self=True)) +.. _iteration-methods: + Available iteration methods (`IterMethod.MODE`):: PRE_ORDER # Depth-first, pre-order diff --git a/nutree/node.py b/nutree/node.py index eac856e..493aa27 100644 --- a/nutree/node.py +++ b/nutree/node.py @@ -1052,8 +1052,8 @@ def visit( callback: TraversalCallbackType, *, add_self=False, - method=IterMethod.PRE_ORDER, - memo=None, + method: IterMethod = IterMethod.PRE_ORDER, + memo: Any = None, ) -> None | Any: """Call `callback(node, memo)` for all subnodes. @@ -1162,7 +1162,7 @@ def _iter_zigzag_rtl(self) -> Iterator[Node]: return self._iter_level(revert=True, toggle=True) def iterator( - self, method=IterMethod.PRE_ORDER, *, add_self=False + self, method: IterMethod = IterMethod.PRE_ORDER, *, add_self=False ) -> Iterator[Node]: """Generator that walks the hierarchy.""" try: diff --git a/nutree/tree.py b/nutree/tree.py index 316e6b4..ae48976 100644 --- a/nutree/tree.py +++ b/nutree/tree.py @@ -307,7 +307,11 @@ def calc_height(self) -> int: return self._root.calc_height() def visit( - self, callback: TraversalCallbackType, *, method=IterMethod.PRE_ORDER, memo=None + self, + callback: TraversalCallbackType, + *, + method: IterMethod = IterMethod.PRE_ORDER, + memo: Any = None, ) -> Any | None: """Call `callback(node, memo)` for all nodes. diff --git a/nutree/typed_tree.py b/nutree/typed_tree.py index 1c21733..a5aac93 100644 --- a/nutree/typed_tree.py +++ b/nutree/typed_tree.py @@ -443,7 +443,7 @@ def filtered(self, predicate: PredicateCallbackType) -> TypedTree: return super().filtered(predicate=predicate) def iterator( - self, method=IterMethod.PRE_ORDER, *, add_self=False + self, method: IterMethod = IterMethod.PRE_ORDER, *, add_self=False ) -> Iterator[Node]: """Generator that walks the hierarchy.""" return super().iterator(method=method, add_self=add_self)