diff --git a/CHANGELOG.md b/CHANGELOG.md index 932f1da8..429b815f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.4.1] - 2026-05-02 ### Changed: -- Tree Search: Modify type hint to include returning None +- Tree Helper: Tree diff modify type hint to include returning None. +- Misc: Mypy type checks to remove ignoring warn_no_return. + +## [1.4.1] - 2026-05-02 +### Changed: +- Tree Search: Modify type hint to include returning None. - Misc: Clean up and remove redundant lines. ## [1.4.0] - 2026-03-24 diff --git a/bigtree/node/basenode.py b/bigtree/node/basenode.py index 84a7eda0..37bde59c 100644 --- a/bigtree/node/basenode.py +++ b/bigtree/node/basenode.py @@ -458,6 +458,7 @@ def left_sibling(self: T) -> T | None: child_idx = children.index(self) if child_idx: return self.parent.children[child_idx - 1] + return None @property def right_sibling(self: T) -> T | None: @@ -471,6 +472,7 @@ def right_sibling(self: T) -> T | None: child_idx = children.index(self) if child_idx + 1 < len(children): return self.parent.children[child_idx + 1] + return None @property def node_path(self: T) -> Iterable[T]: diff --git a/bigtree/tree/helper.py b/bigtree/tree/helper.py index 314ed4b8..d216663e 100644 --- a/bigtree/tree/helper.py +++ b/bigtree/tree/helper.py @@ -441,7 +441,7 @@ def get_tree_diff( aggregate: bool = False, attr_list: Iterable[str] | None = None, fallback_sep: str = "/", -) -> node.Node: +) -> node.Node | None: """Get difference of `tree` to `other_tree`, changes are relative to `tree`. Compares the difference in tree structure (default), but can also compare tree attributes using `attr_list`. @@ -692,3 +692,4 @@ def get_tree_diff( _node = search.find_full_path(tree_diff, path) _node.name += " (~)" return tree_diff + return None diff --git a/bigtree/tree/search.py b/bigtree/tree/search.py index e85b2fce..b93e5199 100644 --- a/bigtree/tree/search.py +++ b/bigtree/tree/search.py @@ -117,8 +117,7 @@ def find(tree: T, condition: Callable[[T], bool], max_depth: int = 0) -> T | Non Search result """ result = findall(tree, condition, max_depth, max_count=1) - if result: - return result[0] + return result[0] if result else None def find_name(tree: NodeT, name: str, max_depth: int = 0) -> NodeT | None: @@ -206,9 +205,7 @@ def find_relative_path(tree: NodeT, path_name: str) -> NodeT | None: Search result """ result = find_relative_paths(tree, path_name, max_count=1) - - if result: - return result[0] + return result[0] if result else None def find_relative_paths( @@ -532,8 +529,7 @@ def find_child( Search result """ result = find_children(tree, condition, max_count=1) - if result: - return result[0] + return result[0] if result else None def find_child_by_name(tree: NodeT | DAGNodeT, name: str) -> NodeT | DAGNodeT | None: diff --git a/pyproject.toml b/pyproject.toml index 992a7481..d05c1d7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -169,7 +169,6 @@ profile = "black" ignore_missing_imports = true strict = true strict_optional = false -warn_no_return = false disallow_untyped_calls = false [tool.ruff]