Skip to content

Commit 2df2f5f

Browse files
committed
fix ruff errors
1 parent 09d9ab8 commit 2df2f5f

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

python/tests/test_pyclass_frozen.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
from pathlib import Path
88
from typing import Iterator
99

10-
PYCLASS_RE = re.compile(r"#\[\s*pyclass\s*(?:\((?P<args>.*?)\))?\s*\]", re.DOTALL)
11-
ARG_STRING_RE = re.compile(r"(?P<key>[A-Za-z_][A-Za-z0-9_]*)\s*=\s*\"(?P<value>[^\"]+)\"")
12-
STRUCT_NAME_RE = re.compile(r"\b(?:pub\s+)?(?:struct|enum)\s+(?P<name>[A-Za-z_][A-Za-z0-9_]*)")
10+
PYCLASS_RE = re.compile(
11+
r"#\[\s*pyclass\s*(?:\((?P<args>.*?)\))?\s*\]",
12+
re.DOTALL,
13+
)
14+
ARG_STRING_RE = re.compile(
15+
r"(?P<key>[A-Za-z_][A-Za-z0-9_]*)\s*=\s*\"(?P<value>[^\"]+)\"",
16+
)
17+
STRUCT_NAME_RE = re.compile(
18+
r"\b(?:pub\s+)?(?:struct|enum)\s+"
19+
r"(?P<name>[A-Za-z_][A-Za-z0-9_]*)",
20+
)
1321

1422

1523
@dataclass
@@ -51,8 +59,9 @@ def iter_pyclasses(root: Path) -> Iterator[PyClass]:
5159

5260
def test_pyclasses_are_frozen() -> None:
5361
allowlist = {
54-
# NOTE: Any new exceptions must include a justification comment in the Rust source
55-
# and, ideally, a follow-up issue to remove the exemption.
62+
# NOTE: Any new exceptions must include a justification comment
63+
# in the Rust source and, ideally, a follow-up issue to remove
64+
# the exemption.
5665
("datafusion.common", "SqlTable"),
5766
("datafusion.common", "SqlView"),
5867
("datafusion.common", "DataTypeMap"),
@@ -66,11 +75,13 @@ def test_pyclasses_are_frozen() -> None:
6675
if not pyclass.frozen and (pyclass.module, pyclass.name) not in allowlist
6776
]
6877

69-
assert not unfrozen, (
70-
"Found pyclasses missing `frozen`; add them to the allowlist only with a "
71-
"justification comment and follow-up plan:\n" +
72-
"\n".join(
73-
f"- {pyclass.module}.{pyclass.name} (defined in {pyclass.source})"
78+
if unfrozen:
79+
msg = (
80+
"Found pyclasses missing `frozen`; add them to the allowlist only "
81+
"with a justification comment and follow-up plan:\n"
82+
)
83+
msg += "\n".join(
84+
(f"- {pyclass.module}.{pyclass.name} (defined in {pyclass.source})")
7485
for pyclass in unfrozen
7586
)
76-
)
87+
assert not unfrozen, msg

0 commit comments

Comments
 (0)