Commit 883c1aed authored by Trond Aasan's avatar Trond Aasan
Browse files

Call repr on self.data

parent 50255a3b
Pipeline #87081 passed with stage
in 37 seconds
......@@ -12,7 +12,7 @@ from typing import (
Optional,
)
__version__ = "0.2.0"
__version__ = "0.3.0"
T = TypeVar("T")
......@@ -45,9 +45,7 @@ class Tree(Generic[T]):
def __repr__(self):
children = ", ".join(list(map(repr, self.children)))
return (
f"Tree(data={self.data}, id_key={repr(self.id_key)}, children=[{children}])"
)
return f"Tree(data={repr(self.data)}, id_key={repr(self.id_key)}, children=[{children}])"
def __eq__(self, other):
return all(
......
[tool.poetry]
name = "bottint-tree"
version = "0.2.0"
version = "0.3.0"
description = ""
authors = ["BOTT-INT <bnt-int@usit.uio.no>"]
homepage = "https://git.app.uib.no/it-bott-integrasjoner/bottint-tree"
......
import itertools
from typing import NamedTuple, Optional, List
from typing import Optional, List
import pytest
......@@ -15,7 +14,7 @@ from bottint_tree import (
def test_version():
assert __version__ == "0.2.0"
assert __version__ == "0.3.0"
def test_poetry_version():
......@@ -26,10 +25,23 @@ def test_poetry_version():
assert version == __version__
class Node(NamedTuple):
class Node:
id: Optional[int]
parent_id: Optional[int]
def __init__(self, id=None, parent_id=None):
self.id = id
self.parent_id = parent_id
def __repr__(self) -> str:
return f"Node(id={repr(self.id)}, parent_id={repr(self.parent_id)})"
def __eq__(self, o) -> bool:
return o.id == self.id and o.parent_id == self.parent_id
def __str__(self) -> str:
return f"id={self.id} parent_id={self.parent_id}"
def _build_forest(items: List[Node]):
return build_forest(items, "id", "parent_id")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment