diff --git a/.flake8 b/.flake8 index 990d7bad9..17e776dd8 100644 --- a/.flake8 +++ b/.flake8 @@ -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 diff --git a/src/.flake8 b/src/.flake8 index 4d43c1bbb..c01df5c81 100644 --- a/src/.flake8 +++ b/src/.flake8 @@ -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 diff --git a/src/dso_api/settings.py b/src/dso_api/settings.py index 28e01bc2e..b43cfc4b6 100644 --- a/src/dso_api/settings.py +++ b/src/dso_api/settings.py @@ -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": [], } } diff --git a/src/rest_framework_dso/renderers.py b/src/rest_framework_dso/renderers.py index 5295b690b..0038e584d 100644 --- a/src/rest_framework_dso/renderers.py +++ b/src/rest_framework_dso/renderers.py @@ -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() diff --git a/src/rest_framework_dso/response.py b/src/rest_framework_dso/response.py index da38f99db..95a5a708e 100644 --- a/src/rest_framework_dso/response.py +++ b/src/rest_framework_dso/response.py @@ -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( @@ -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 diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 919a44d0d..3e6f31f7e 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -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 diff --git a/src/tests/utils.py b/src/tests/utils.py index e27790a4c..41e4e4729 100644 --- a/src/tests/utils.py +++ b/src/tests/utils.py @@ -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