Skip to content

Commit f03f672

Browse files
authored
fix: ruff new lint rules (#361)
1 parent ac9cc54 commit f03f672

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ python-semantic-release = "^8.7.0"
3838
[tool.ruff]
3939
fix = true
4040
line-length = 88
41+
42+
[tool.ruff.lint]
4143
select = [
4244
"E", # pycodestyle errors
4345
"W", # pycodestyle warnings

src/unfold/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def _filter_unfold_actions_by_permissions(
400400
filtered_actions.append(action)
401401
continue
402402
permission_checks = (
403-
getattr(self, "has_%s_permission" % permission)
403+
getattr(self, f"has_{permission}_permission")
404404
for permission in action.method.allowed_permissions
405405
)
406406
if any(has_permission(request) for has_permission in permission_checks):

src/unfold/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _check_unfold_action_permission_methods(self, obj: Any) -> List[checks.Error
3030
if not hasattr(action.method, "allowed_permissions"):
3131
continue
3232
for permission in action.method.allowed_permissions:
33-
method_name = "has_%s_permission" % permission
33+
method_name = f"has_{permission}_permission"
3434
if not hasattr(obj, method_name):
3535
errors.append(
3636
checks.Error(

src/unfold/templatetags/unfold_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def result_headers(cl):
149149
if is_sorted:
150150
order_type = ordering_field_columns.get(i).lower()
151151
sort_priority = list(ordering_field_columns).index(i) + 1
152-
th_classes.append("sorted %sending" % order_type)
152+
th_classes.append(f"sorted {order_type}ending")
153153
new_order_type = {"asc": "desc", "desc": "asc"}[order_type]
154154

155155
# build new ordering param
@@ -211,7 +211,7 @@ def link_in_col(is_first: bool, field_name: str, cl: ChangeList) -> bool:
211211
for field_index, field_name in enumerate(cl.list_display):
212212
empty_value_display = cl.model_admin.get_empty_value_display()
213213
row_classes = [
214-
"field-%s" % _coerce_field_name(field_name, field_index),
214+
f"field-{_coerce_field_name(field_name, field_index)}",
215215
*ROW_CLASSES,
216216
]
217217

@@ -252,7 +252,7 @@ def link_in_col(is_first: bool, field_name: str, cl: ChangeList) -> bool:
252252
f, (models.DateField, models.TimeField, models.ForeignKey)
253253
):
254254
row_classes.append("nowrap")
255-
row_class = mark_safe(' class="%s"' % " ".join(row_classes))
255+
row_class = mark_safe(f' class="{" ".join(row_classes)}"')
256256
# If list_display_links not defined, add the link tag to the first field
257257

258258
if link_in_col(first, field_name, cl):

0 commit comments

Comments
 (0)