Skip to content

Commit 7add9a1

Browse files
committed
simpler linter
1 parent 6d17545 commit 7add9a1

File tree

4 files changed

+16
-36
lines changed

4 files changed

+16
-36
lines changed

hypothesis-python/tests/cover/test_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_extract_bits_roundtrip(width, x):
150150
assert x == sum(v << p for p, v in enumerate(reversed(bits)))
151151

152152

153-
@dataclass(frozen=True)
153+
@dataclass(frozen=True, slots=False)
154154
class ImmutableError:
155155
msg: str
156156

hypothesis-python/tests/cover/test_lookup_py38.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_layered_optional_key_is_optional():
120120
find_any(from_type(C), lambda d: "b" not in d)
121121

122122

123-
@dataclasses.dataclass()
123+
@dataclasses.dataclass(slots=False, frozen=False)
124124
class Node:
125125
left: typing.Union["Node", int]
126126
right: typing.Union["Node", int]

tooling/src/hypothesistooling/__main__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ def lint():
8282
pip_tool("ruff", "check", ".")
8383
codespell(*(p for p in tools.all_files() if not p.name.endswith("by-domain.txt")))
8484

85+
matches = subprocess.run(
86+
r"git grep -En '@(dataclasses\.)?dataclass\(.*\)' "
87+
"| grep -Ev 'frozen=.*slots=|slots=.*frozen='",
88+
shell=True,
89+
capture_output=True,
90+
text=True,
91+
).stdout
92+
if matches:
93+
from textwrap import indent
94+
95+
print("\nAll dataclass decorators must pass slots= and frozen= arguments:")
96+
print(indent(matches, " "))
97+
sys.exit(1)
98+
8599

86100
def do_release(package):
87101
if not package.has_release():

whole_repo_tests/whole_repo/test_dataclass.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)