Skip to content

Commit 2f3e98a

Browse files
committed
updates ruff rules
1 parent 3347aa5 commit 2f3e98a

File tree

5 files changed

+33
-41
lines changed

5 files changed

+33
-41
lines changed

pyproject.toml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,34 @@ lint.select = [
8585
"ALL",
8686
]
8787
lint.ignore = [
88-
"ANN401", # Dynamically typed expressions
88+
"A",
89+
"ANN",
90+
"ARG", # Unused function argument:
91+
"B",
92+
"BLE",
8993
"COM812",
9094
"CPY", # Missing copyright notice
9195
"D", # docstring
9296
"DOC", # docstring
93-
"E731", # Do not assign a `lambda` expression,
94-
"EM101", # Exception must not use a string literal, assign to variable first
95-
"EM102", # Exception must not use a f-string literal, assign to variable first
96-
"FBT001", # Boolean-typed positional argument in function definition
97-
"FBT002", # Boolean default positional argument in function definition
98-
"N806", # Variable `...` in function should be lowercase
99-
"S308", # Use of `mark_safe` may expose cross-site scripting vulnerabilities
100-
"SLF001", # Private member accessed: `...`
101-
"TRY003", # Avoid specifying long messages outside the exception class
102-
"TRY301", # Abstract `raise` to an inner function
103-
"TRY401", # Redundant exception object included in `logging.exception` call
104-
"UP037", #
97+
"EM",
98+
"EXE",
99+
"ERA",
100+
"FBT",
101+
"G",
102+
"N",
103+
"PERF",
104+
"PLC",
105+
"PLR",
106+
"PLW",
107+
"PGH",
108+
"PT",
109+
"RUF",
110+
"S",
111+
"SIM",
112+
"SLF",
113+
"TRY",
114+
"UP",
115+
105116
]
106117
lint.per-file-ignores."docs/conf.py" = [
107118
"A001", #

src/concurrency/admin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ def response_action(self, request, queryset): # noqa
125125
"A tuple with `primary_key, version_number` "
126126
f"expected: `{x}` found"
127127
)
128-
raise ImproperlyConfigured(
129-
msg
130-
)
128+
raise ImproperlyConfigured(msg)
131129
filters.append(Q(**{"pk": pk, revision_field.attname: version}))
132130

133131
queryset = queryset.filter(reduce(operator.or_, filters))

src/concurrency/config.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ def _set_attr(self, prefix_name, value) -> None:
6464
elif callable(value):
6565
func = value
6666
else:
67-
msg = (
68-
f"{value} is not a valid value for `CALLBACK`. It must be a callable or a fullpath to callable. "
69-
)
70-
raise ImproperlyConfigured(
71-
msg
72-
)
67+
msg = f"{value} is not a valid value for `CALLBACK`. It must be a callable or a fullpath to callable. "
68+
raise ImproperlyConfigured(msg)
7369
self._callback = func
7470
elif name == "TRIGGERS_FACTORY":
7571
original = dict(value)

src/concurrency/triggers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,10 @@ def create(self, field) -> None:
128128
try:
129129
self.connection.cursor().execute(stm)
130130
except BaseException as exc: # pragma: no cover
131-
msg = (
132-
f"""Error executing:
131+
msg = f"""Error executing:
133132
{stm}
134133
{exc}"""
135-
)
136-
raise DatabaseError(
137-
msg
138-
)
134+
raise DatabaseError(msg)
139135
else: # pragma: no cover
140136
pass
141137
field._trigger_exists = True

src/concurrency/utils.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_concurrency_conflict(self) -> None:
7878
target_copy = self._get_concurrency_target()
7979
v1 = api.get_revision_of_object(target)
8080
v2 = api.get_revision_of_object(target_copy)
81-
assert v1 == v2, f"got same row with different version ({v1}/{v2})"
81+
assert v1 == v2, f"got same row with different version ({v1}/{v2})" # noqa: S101
8282
target.save()
8383
assert target.pk is not None # sanity check
8484
self.assertRaises(RecordModifiedError, target_copy.save)
@@ -88,15 +88,15 @@ def test_concurrency_safety(self) -> None:
8888

8989
target = self.concurrency_model()
9090
version = api.get_revision_of_object(target)
91-
assert not bool(version), f"version is not null {version}"
91+
assert not bool(version), f"version is not null {version}" # noqa: S101
9292

9393
def test_concurrency_management(self) -> None:
9494
target = self.concurrency_model
95-
assert hasattr(target, "_concurrencymeta"), f"{self.concurrency_model} is not under concurrency management"
95+
assert hasattr(target, "_concurrencymeta"), f"{self.concurrency_model} is not under concurrency management" # noqa: S101
9696

9797
revision_field = target._concurrencymeta.field
9898

99-
assert revision_field in target._meta.fields, f"{self.concurrency_model}: version field not in meta.fields"
99+
assert revision_field in target._meta.fields, f"{self.concurrency_model}: version field not in meta.fields" # noqa: S101
100100

101101

102102
class ConcurrencyAdminTestMixin:
@@ -153,15 +153,6 @@ def fqn(o):
153153
"""
154154
parts = []
155155

156-
# if inspect.ismethod(o):
157-
# try:
158-
# cls = o.im_class
159-
# except AttributeError:
160-
# # Python 3 eliminates im_class, substitutes __module__ and
161-
# # __qualname__ to provide similar information.
162-
# parts = (o.__module__, o.__qualname__)
163-
# else:
164-
# parts = (fqn(cls), get_classname(o))
165156
if hasattr(o, "__module__"):
166157
parts.extend((o.__module__, get_classname(o)))
167158
elif inspect.ismodule(o):

0 commit comments

Comments
 (0)