Skip to content

Commit

Permalink
Pass pyright 'standard'
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Oct 28, 2024
1 parent de2dbcc commit a7ab740
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions nutree/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion nutree/typed_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Declare the :class:`~nutree.tree.TypedTree` class.
"""
# pyright: reportIncompatibleMethodOverride=false

from __future__ import annotations

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ignore = [
# convention = "google"

[tool.pyright]
typeCheckingMode = "basic"
typeCheckingMode = "standard"
# typeCheckingMode = "off"
reportMissingImports = "none"
# include = ["nutree"]
Expand Down
1 change: 1 addition & 0 deletions tests/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 6 additions & 3 deletions tests/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_typing_concept.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ruff: noqa: T201, T203 `print` found
# pyright: reportIncompatibleMethodOverride=false

from __future__ import annotations

Expand Down

0 comments on commit a7ab740

Please sign in to comment.