diff --git a/pyproject.toml b/pyproject.toml index c632b2bdb..ad57889ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,8 @@ python-semantic-release = "^8.7.0" [tool.ruff] fix = true line-length = 88 + +[tool.ruff.lint] select = [ "E", # pycodestyle errors "W", # pycodestyle warnings diff --git a/src/unfold/admin.py b/src/unfold/admin.py index 3bea67b61..155ec43f7 100644 --- a/src/unfold/admin.py +++ b/src/unfold/admin.py @@ -400,7 +400,7 @@ def _filter_unfold_actions_by_permissions( filtered_actions.append(action) continue permission_checks = ( - getattr(self, "has_%s_permission" % permission) + getattr(self, f"has_{permission}_permission") for permission in action.method.allowed_permissions ) if any(has_permission(request) for has_permission in permission_checks): diff --git a/src/unfold/checks.py b/src/unfold/checks.py index e2c25bda2..504aa6415 100644 --- a/src/unfold/checks.py +++ b/src/unfold/checks.py @@ -30,7 +30,7 @@ def _check_unfold_action_permission_methods(self, obj: Any) -> List[checks.Error if not hasattr(action.method, "allowed_permissions"): continue for permission in action.method.allowed_permissions: - method_name = "has_%s_permission" % permission + method_name = f"has_{permission}_permission" if not hasattr(obj, method_name): errors.append( checks.Error( diff --git a/src/unfold/templatetags/unfold_list.py b/src/unfold/templatetags/unfold_list.py index a4a43b1c1..a563e6010 100644 --- a/src/unfold/templatetags/unfold_list.py +++ b/src/unfold/templatetags/unfold_list.py @@ -149,7 +149,7 @@ def result_headers(cl): if is_sorted: order_type = ordering_field_columns.get(i).lower() sort_priority = list(ordering_field_columns).index(i) + 1 - th_classes.append("sorted %sending" % order_type) + th_classes.append(f"sorted {order_type}ending") new_order_type = {"asc": "desc", "desc": "asc"}[order_type] # build new ordering param @@ -211,7 +211,7 @@ def link_in_col(is_first: bool, field_name: str, cl: ChangeList) -> bool: for field_index, field_name in enumerate(cl.list_display): empty_value_display = cl.model_admin.get_empty_value_display() row_classes = [ - "field-%s" % _coerce_field_name(field_name, field_index), + f"field-{_coerce_field_name(field_name, field_index)}", *ROW_CLASSES, ] @@ -252,7 +252,7 @@ def link_in_col(is_first: bool, field_name: str, cl: ChangeList) -> bool: f, (models.DateField, models.TimeField, models.ForeignKey) ): row_classes.append("nowrap") - row_class = mark_safe(' class="%s"' % " ".join(row_classes)) + row_class = mark_safe(f' class="{" ".join(row_classes)}"') # If list_display_links not defined, add the link tag to the first field if link_in_col(first, field_name, cl):