Skip to content

Commit 2e0a1b9

Browse files
authored
Merge pull request #274 from c0fec0de/remove-six
fixes #249, fixes #250
2 parents b8c1d25 + f44de1a commit 2e0a1b9

File tree

8 files changed

+7
-55
lines changed

8 files changed

+7
-55
lines changed

pyproject.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ name = "anytree"
44
dynamic = ["version"]
55
description = "Powerful and Lightweight Python Tree Data Structure with various plugins"
66
authors = [{ name = "c0fec0de", email = "[email protected]" }]
7-
dependencies = [
8-
"six>=1.17.0",
9-
]
7+
dependencies = []
108
requires-python = ">=3.9.2,<4.0"
119
readme = "README.rst"
1210
license = "Apache-2.0"
@@ -38,7 +36,6 @@ dev = [
3836
"sphinx-rtd-theme>=2.0.0",
3937
"sphinxemoji>=0.3.1",
4038
"test2ref>=0.4.2",
41-
"types-six>=1.17.0.20250403",
4239
]
4340

4441
[build-system]

src/anytree/exporter/dotexporter.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from subprocess import check_call
77
from tempfile import NamedTemporaryFile
88

9-
import six
10-
119
from anytree import PreOrderIter
1210

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

311309

312310
class UniqueDotExporter(DotExporter):

src/anytree/exporter/mermaidexporter.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import itertools
33
import re
44

5-
import six
6-
75
from anytree import PreOrderIter
86

97
_RE_ESC = re.compile(r'["\\]')
@@ -232,4 +230,4 @@ def to_file(self, filename):
232230
@staticmethod
233231
def esc(value):
234232
"""Escape Strings."""
235-
return _RE_ESC.sub(lambda m: rf"\{m.group(0)}", six.text_type(value))
233+
return _RE_ESC.sub(lambda m: rf"\{m.group(0)}", str(value))

src/anytree/iterators/abstractiter.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import six
2-
3-
4-
class AbstractIter(six.Iterator):
1+
class AbstractIter:
52
# pylint: disable=R0205
63
"""
74
Iterate over tree starting at `node`.

src/anytree/render.py

-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import collections
1212

13-
import six
14-
1513
from .config import ASSERTIONS
1614

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

148146

149-
@six.python_2_unicode_compatible
150147
class RenderTree:
151148
"""
152149
Render tree starting at `node`.

tests/helper.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Helper Methods for testing."""
22

33
from contextlib import contextmanager
4-
from subprocess import run
54

65

76
def eq_(one, other):
@@ -18,13 +17,3 @@ def assert_raises(exccls, msg):
1817
except Exception as exc:
1918
assert isinstance(exc, exccls), f"{exc!r} is not a {exccls!r}"
2019
eq_(str(exc), msg)
21-
22-
23-
def is_installed(cmd: tuple[str, ...]) -> bool:
24-
try:
25-
return run(cmd, check=False).returncode == 0
26-
except FileNotFoundError:
27-
return False
28-
29-
30-
GRAPHVIZ_INSTALLED = is_installed(("dot", "--version"))

tests/test_dotexport.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from shutil import which
2+
13
from pytest import mark
24
from test2ref import assert_refdata
35

46
from anytree import Node
57
from anytree.dotexport import RenderTreeGraph
68

7-
from .helper import GRAPHVIZ_INSTALLED
8-
99

1010
def test_tree1(tmp_path):
1111
"""Tree1."""
@@ -53,7 +53,7 @@ def edgeattrfunc(node, child):
5353
assert_refdata(test_tree2, tmp_path)
5454

5555

56-
@mark.skipif(not GRAPHVIZ_INSTALLED, reason="graphviz missing")
56+
@mark.skipif(which("dot") is None, reason="requires graphviz`s `dot` command")
5757
def test_tree_png(tmp_path):
5858
"""Tree to png."""
5959
root = Node("root")

uv.lock

-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)