Skip to content

Commit 768850d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bb17d11 commit 768850d

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

src/tox/journal/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import locale
65
from pathlib import Path
76
from typing import TYPE_CHECKING
87

src/tox/plugin/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,6 @@ def tox_register_report_formatter(register: ReportFormatterRegister) -> None:
142142
"tox_env_teardown",
143143
"tox_extend_envs",
144144
"tox_on_install",
145-
"tox_register_tox_env",
146145
"tox_register_report_formatter",
146+
"tox_register_tox_env",
147147
]

src/tox/report/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Report formatting system for tox."""
22

3-
__all__ = ()
3+
from __future__ import annotations
44

5+
__all__ = ()

src/tox/report/config.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
from __future__ import annotations
44

55
from tox.plugin import impl
6-
from tox.report.formatter import REGISTER
76

87

98
@impl
10-
def tox_add_core_config(core_conf, state): # noqa: ARG001
9+
def tox_add_core_config(core_conf, state) -> None: # noqa: ARG001
1110
"""Add report_format configuration to core config."""
1211
core_conf.add_config(
1312
keys=["report_format"],
@@ -18,7 +17,7 @@ def tox_add_core_config(core_conf, state): # noqa: ARG001
1817

1918

2019
@impl
21-
def tox_add_env_config(env_conf, state): # noqa: ARG001
20+
def tox_add_env_config(env_conf, state) -> None: # noqa: ARG001
2221
"""Add report_format configuration to environment config (inherits from core if not set)."""
2322
env_conf.add_config(
2423
keys=["report_format"],
@@ -29,4 +28,3 @@ def tox_add_env_config(env_conf, state): # noqa: ARG001
2928

3029

3130
__all__ = ()
32-

src/tox/report/formatter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from __future__ import annotations
44

55
import abc
6-
from typing import TYPE_CHECKING, Any
7-
8-
from tox.journal.main import Journal
6+
from typing import TYPE_CHECKING
97

108
if TYPE_CHECKING:
119
from pathlib import Path
1210

11+
from tox.journal.main import Journal
12+
1313

1414
class ReportFormatter(abc.ABC):
1515
"""Base class for test report formatters."""
@@ -74,8 +74,7 @@ def list_formatters(self) -> list[str]:
7474
REGISTER = ReportFormatterRegister()
7575

7676
__all__ = (
77+
"REGISTER",
7778
"ReportFormatter",
7879
"ReportFormatterRegister",
79-
"REGISTER",
8080
)
81-

src/tox/report/formatters/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
"JsonFormatter",
1010
"XmlFormatter",
1111
)
12-

src/tox/report/formatters/json.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
import json
66
import locale
77
from pathlib import Path
8+
from typing import TYPE_CHECKING
89

9-
from tox.journal.main import Journal
1010
from tox.report.formatter import ReportFormatter
1111

12+
if TYPE_CHECKING:
13+
from tox.journal.main import Journal
14+
1215

1316
class JsonFormatter(ReportFormatter):
1417
"""JSON format report formatter."""
@@ -34,4 +37,3 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
3437

3538

3639
__all__ = ("JsonFormatter",)
37-

src/tox/report/formatters/xml.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
import locale
66
from pathlib import Path
7-
from xml.etree import ElementTree
7+
from typing import TYPE_CHECKING
8+
from xml.etree import ElementTree as ET
89

9-
from tox.journal.main import Journal
1010
from tox.report.formatter import ReportFormatter
1111

12+
if TYPE_CHECKING:
13+
from tox.journal.main import Journal
14+
1215

1316
class XmlFormatter(ReportFormatter):
1417
"""JUnit XML format report formatter."""
@@ -25,7 +28,7 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
2528
content = journal.content
2629

2730
# Create root testsuites element
28-
testsuites = ElementTree.Element("testsuites")
31+
testsuites = ET.Element("testsuites")
2932

3033
# Add metadata
3134
if "toxversion" in content:
@@ -43,7 +46,7 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
4346
# Process each test environment
4447
testenvs = content.get("testenvs", {})
4548
for env_name, env_data in testenvs.items():
46-
testsuite = ElementTree.SubElement(testsuites, "testsuite")
49+
testsuite = ET.SubElement(testsuites, "testsuite")
4750
testsuite.set("name", env_name)
4851

4952
env_tests = 0
@@ -57,7 +60,7 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
5760

5861
# Process setup commands
5962
for setup in setup_results:
60-
testcase = ElementTree.SubElement(testsuite, "testcase")
63+
testcase = ET.SubElement(testsuite, "testcase")
6164
testcase.set("classname", env_name)
6265
testcase.set("name", f"setup:{setup.get('run_id', 'unknown')}")
6366
elapsed = float(setup.get("elapsed", 0.0))
@@ -66,14 +69,14 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
6669
env_tests += 1
6770

6871
if setup.get("retcode", 0) != 0:
69-
failure = ElementTree.SubElement(testcase, "failure")
72+
failure = ET.SubElement(testcase, "failure")
7073
failure.set("message", f"Setup command failed with exit code {setup.get('retcode')}")
7174
failure.text = setup.get("err", "")
7275
env_errors += 1
7376

7477
# Process test commands
7578
for test in test_results:
76-
testcase = ElementTree.SubElement(testsuite, "testcase")
79+
testcase = ET.SubElement(testsuite, "testcase")
7780
testcase.set("classname", env_name)
7881
testcase.set("name", test.get("command", test.get("run_id", "unknown")))
7982
elapsed = float(test.get("elapsed", 0.0))
@@ -83,7 +86,7 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
8386

8487
retcode = test.get("retcode", 0)
8588
if retcode != 0:
86-
failure = ElementTree.SubElement(testcase, "failure")
89+
failure = ET.SubElement(testcase, "failure")
8790
failure.set("message", f"Test command failed with exit code {retcode}")
8891
failure.text = test.get("err", test.get("output", ""))
8992
env_failures += 1
@@ -111,10 +114,10 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
111114

112115
# Convert to XML string
113116
try:
114-
ElementTree.indent(testsuites, space=" ") # Python 3.9+
117+
ET.indent(testsuites, space=" ") # Python 3.9+
115118
except AttributeError:
116119
pass # ElementTree.indent not available in older Python versions
117-
xml_content = ElementTree.tostring(testsuites, encoding="unicode", xml_declaration=True)
120+
xml_content = ET.tostring(testsuites, encoding="unicode", xml_declaration=True)
118121

119122
if output_path is not None:
120123
with Path(output_path).open("w", encoding=locale.getpreferredencoding(do_setlocale=False)) as file_handler:
@@ -125,4 +128,3 @@ def format(self, journal: Journal, output_path: Path | None = None) -> str | Non
125128

126129

127130
__all__ = ("XmlFormatter",)
128-

0 commit comments

Comments
 (0)