Skip to content

Commit

Permalink
Fix flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Yrob committed Jun 10, 2024
1 parent 8b934c7 commit d0499f8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ extend-ignore=
W503,
exclude=.git,
**/migrations/*,
docs,
**/doc.py,
scripts,
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
max-complexity=8
Expand Down
1 change: 1 addition & 0 deletions src/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ignore=
exclude=.git,
**/migrations/*,
docs,
**/doc.py,
scripts,
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
max-complexity=8
Expand Down
2 changes: 1 addition & 1 deletion src/dso_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
"EXPORTER": f"""opencensus.ext.azure.trace_exporter.AzureExporter(
connection_string='{AZURE_APPI_CONNECTION_STRING}',
service_name='dso-api'
)""",
)""", # noqa: E202
"EXCLUDELIST_PATHS": [],
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rest_framework_dso/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def _chunked_output(stream, chunk_size=DEFAULT_CHUNK_SIZE, write_exception=None)
buffer.truncate(0)
if buffer.tell():
yield buffer.getvalue()
except Exception as e:
except Exception as e: # noqa: B902
# Write the last bit that gives some hint on where it stalled:
if buffer.tell():
yield buffer.getvalue()
Expand Down
6 changes: 4 additions & 2 deletions src/rest_framework_dso/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def from_response(cls, response: Response):
if content_type is None and hasattr(response, "accepted_renderer"):
media_type = response.accepted_renderer.media_type
charset = response.accepted_renderer.charset
content_type = f"{media_type}; charset={charset}" if charset else media_type
content_type = (
f"{media_type}; charset={charset}" if charset else media_type
) # noqa: E702
response["Content-Type"] = content_type

streaming_response = cls(
Expand Down Expand Up @@ -95,7 +97,7 @@ def _read_rendered_content(self):

try:
yield from stream
except Exception as e:
except Exception as e: # noqa: B902
yield self.render_exception(e)
raise # stops the server rendering

Expand Down
2 changes: 1 addition & 1 deletion src/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _get_model(self, dataset_name, model_name):
except KeyError:
available = ",".join(sorted(app.keys()))
raise KeyError(
f"Model {model_name} does not exist in dataset '{dataset_name}'. "
f"Model {model_name} does not exist in dataset '{dataset_name}'. " # noqa: E713
f"Available are: {available}"
) from None

Expand Down
2 changes: 1 addition & 1 deletion src/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def read_response_partial(response: HttpResponseBase) -> tuple[str, Optional[Exc
try:
for chunk in iter(response):
buffer.write(chunk)
except Exception as e:
except Exception as e: # noqa: B902
return buffer.getvalue().decode(), e
else:
return buffer.getvalue().decode(), None
Expand Down

0 comments on commit d0499f8

Please sign in to comment.