From a7ab7404a36b0bcc58ae0e52319f6e9917ae6367 Mon Sep 17 00:00:00 2001 From: Martin Wendt Date: Mon, 28 Oct 2024 21:37:32 +0100 Subject: [PATCH] Pass pyright 'standard' --- nutree/node.py | 1 + nutree/typed_tree.py | 3 ++- pyproject.toml | 2 +- tests/fixture.py | 1 + tests/test_serialize.py | 9 ++++++--- tests/test_typing_concept.py | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/nutree/node.py b/nutree/node.py index e58d09c..4bd6577 100644 --- a/nutree/node.py +++ b/nutree/node.py @@ -620,6 +620,7 @@ def add_child( topnodes = child._root.children if isinstance(before, (int, Node)) or before is True: topnodes.reverse() + n = None for n in topnodes: self.add_child(n, before=before, deep=deep) return cast(Self, n) # need to return a node diff --git a/nutree/typed_tree.py b/nutree/typed_tree.py index b0c47ad..4c97baa 100644 --- a/nutree/typed_tree.py +++ b/nutree/typed_tree.py @@ -3,6 +3,7 @@ """ Declare the :class:`~nutree.tree.TypedTree` class. """ +# pyright: reportIncompatibleMethodOverride=false from __future__ import annotations @@ -691,7 +692,7 @@ class _SystemRootTypedNode(TypedNode): """Invisible system root node.""" def __init__(self, tree: TypedTree) -> None: - self._tree: TypedTree = tree + self._tree: TypedTree = tree # type: ignore self._parent = None # type: ignore self._node_id = ROOT_NODE_ID self._data_id = ROOT_DATA_ID diff --git a/pyproject.toml b/pyproject.toml index 788e4d7..db614b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ ignore = [ # convention = "google" [tool.pyright] -typeCheckingMode = "basic" +typeCheckingMode = "standard" # typeCheckingMode = "off" reportMissingImports = "none" # include = ["nutree"] diff --git a/tests/fixture.py b/tests/fixture.py index d9fb131..5376118 100644 --- a/tests/fixture.py +++ b/tests/fixture.py @@ -415,6 +415,7 @@ def callback(number: int, time_taken: float): # return 1 def format_time(dt): + scale = 0 unit = time_unit if unit is not None: scale = units[unit] diff --git a/tests/test_serialize.py b/tests/test_serialize.py index 6b5905c..5af8c6a 100644 --- a/tests/test_serialize.py +++ b/tests/test_serialize.py @@ -492,7 +492,8 @@ def calc_data_id(self, data): return data.guid return hash(data) - def serialize_mapper(self, node: Node, data: dict) -> dict | None: + @classmethod + def serialize_mapper(cls, node: Node, data: dict) -> dict | None: if isinstance(node.data, fixture.Department): data["type"] = "dept" data["name"] = node.data.name @@ -502,8 +503,10 @@ def serialize_mapper(self, node: Node, data: dict) -> dict | None: data["age"] = node.data.age return data - @staticmethod - def deserialize_mapper(parent: Node, data: dict) -> str | object | None: + @classmethod + def deserialize_mapper( + cls, parent: Node, data: dict + ) -> str | object | None: node_type = data["type"] print("deserialize_mapper", data) res = data diff --git a/tests/test_typing_concept.py b/tests/test_typing_concept.py index 023241d..25fecde 100644 --- a/tests/test_typing_concept.py +++ b/tests/test_typing_concept.py @@ -1,4 +1,5 @@ # ruff: noqa: T201, T203 `print` found +# pyright: reportIncompatibleMethodOverride=false from __future__ import annotations