Skip to content

fixes #249, fixes #250 #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ name = "anytree"
dynamic = ["version"]
description = "Powerful and Lightweight Python Tree Data Structure with various plugins"
authors = [{ name = "c0fec0de", email = "[email protected]" }]
dependencies = [
"six>=1.17.0",
]
dependencies = []
requires-python = ">=3.9.2,<4.0"
readme = "README.rst"
license = "Apache-2.0"
Expand Down Expand Up @@ -38,7 +36,6 @@ dev = [
"sphinx-rtd-theme>=2.0.0",
"sphinxemoji>=0.3.1",
"test2ref>=0.4.2",
"types-six>=1.17.0.20250403",
]

[build-system]
Expand Down
4 changes: 1 addition & 3 deletions src/anytree/exporter/dotexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from subprocess import check_call
from tempfile import NamedTemporaryFile

import six

from anytree import PreOrderIter

_RE_ESC = re.compile(r'["\\]')
Expand Down Expand Up @@ -306,7 +304,7 @@ def to_picture(self, filename):
@staticmethod
def esc(value):
"""Escape Strings."""
return _RE_ESC.sub(lambda m: rf"\{m.group(0)}", six.text_type(value))
return _RE_ESC.sub(lambda m: rf"\{m.group(0)}", str(value))


class UniqueDotExporter(DotExporter):
Expand Down
4 changes: 1 addition & 3 deletions src/anytree/exporter/mermaidexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import itertools
import re

import six

from anytree import PreOrderIter

_RE_ESC = re.compile(r'["\\]')
Expand Down Expand Up @@ -232,4 +230,4 @@ def to_file(self, filename):
@staticmethod
def esc(value):
"""Escape Strings."""
return _RE_ESC.sub(lambda m: rf"\{m.group(0)}", six.text_type(value))
return _RE_ESC.sub(lambda m: rf"\{m.group(0)}", str(value))
5 changes: 1 addition & 4 deletions src/anytree/iterators/abstractiter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import six


class AbstractIter(six.Iterator):
class AbstractIter:
# pylint: disable=R0205
"""
Iterate over tree starting at `node`.
Expand Down
3 changes: 0 additions & 3 deletions src/anytree/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import collections

import six

from .config import ASSERTIONS

Row = collections.namedtuple("Row", ("pre", "fill", "node"))
Expand Down Expand Up @@ -146,7 +144,6 @@ def __init__(self):
super().__init__("\u2551 ", "\u2560\u2550\u2550 ", "\u255a\u2550\u2550 ")


@six.python_2_unicode_compatible
class RenderTree:
"""
Render tree starting at `node`.
Expand Down
11 changes: 0 additions & 11 deletions tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Helper Methods for testing."""

from contextlib import contextmanager
from subprocess import run


def eq_(one, other):
Expand All @@ -18,13 +17,3 @@ def assert_raises(exccls, msg):
except Exception as exc:
assert isinstance(exc, exccls), f"{exc!r} is not a {exccls!r}"
eq_(str(exc), msg)


def is_installed(cmd: tuple[str, ...]) -> bool:
try:
return run(cmd, check=False).returncode == 0
except FileNotFoundError:
return False


GRAPHVIZ_INSTALLED = is_installed(("dot", "--version"))
6 changes: 3 additions & 3 deletions tests/test_dotexport.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from shutil import which

from pytest import mark
from test2ref import assert_refdata

from anytree import Node
from anytree.dotexport import RenderTreeGraph

from .helper import GRAPHVIZ_INSTALLED


def test_tree1(tmp_path):
"""Tree1."""
Expand Down Expand Up @@ -53,7 +53,7 @@ def edgeattrfunc(node, child):
assert_refdata(test_tree2, tmp_path)


@mark.skipif(not GRAPHVIZ_INSTALLED, reason="graphviz missing")
@mark.skipif(which("dot") is None, reason="requires graphviz`s `dot` command")
def test_tree_png(tmp_path):
"""Tree to png."""
root = Node("root")
Expand Down
24 changes: 0 additions & 24 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.