Skip to content

Commit 6cbaa39

Browse files
committed
Run Ruff on the whole codebase
1 parent fc25921 commit 6cbaa39

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

drf_excel/fields.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def __init__(self, **kwargs):
8585
super().__init__(**kwargs)
8686

8787
def init_value(self, value):
88-
8988
with contextlib.suppress(Exception):
9089
if isinstance(self.drf_field, IntegerField) and type(value) != int:
9190
return int(value)
@@ -160,7 +159,11 @@ def __init__(self, list_sep, **kwargs):
160159
super().__init__(**kwargs)
161160

162161
def prep_value(self) -> Any:
163-
if len(self.value) > 0 and isinstance(self.value[0], Iterable) and not isinstance(self.value[0], str):
162+
if (
163+
len(self.value) > 0
164+
and isinstance(self.value[0], Iterable)
165+
and not isinstance(self.value[0], str)
166+
):
164167
# array of array; write as json
165168
return json.dumps(self.value, ensure_ascii=False)
166169
else:

drf_excel/mixins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def finalize_response(self, request, response, *args, **kwargs):
2121
Return the response with the proper content disposition and the customized
2222
filename instead of the browser default (or lack thereof).
2323
"""
24-
response = super().finalize_response(
25-
request, response, *args, **kwargs
26-
)
24+
response = super().finalize_response(request, response, *args, **kwargs)
2725
if (
2826
isinstance(response, Response)
2927
and response.accepted_renderer.format == "xlsx"

drf_excel/renderers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ def _flatten_serializer_keys(
266266

267267
def _get_label(parent_label, label_sep, obj):
268268
if getattr(v, "label", None):
269-
return f"{parent_label}{label_sep}{v.label}" if parent_label else str(v.label)
269+
return (
270+
f"{parent_label}{label_sep}{v.label}"
271+
if parent_label
272+
else str(v.label)
273+
)
270274
else:
271275
return False
272276

@@ -346,9 +350,7 @@ def _make_body(self, body, row, row_count):
346350

347351
if "row_color" in row:
348352
last_letter = get_column_letter(column_count)
349-
cell_range = self.ws[
350-
f"A{row_count}" : f"{last_letter}{row_count}"
351-
]
353+
cell_range = self.ws[f"A{row_count}" : f"{last_letter}{row_count}"]
352354
fill = PatternFill(fill_type="solid", start_color=row["row_color"])
353355

354356
for r in cell_range:

0 commit comments

Comments
 (0)