bito-code-review[bot] commented on PR #40801:
URL: https://github.com/apache/superset/pull/40801#issuecomment-4631202996
<!-- Bito Reply -->
The flagged issue is correct. Accessing `app.config["CSV_EXPORT"]` directly
will raise a `KeyError` if the key is missing in the application configuration.
To resolve this, you should use `.get()` on the `app.config` object to safely
retrieve the dictionary, and then access the encoding key from that result.
Here is the corrected implementation for `superset/views/base.py`:
```python
def __init__(self, response: Any = None, *args: Any, **kwargs: Any) ->
None:
csv_export = app.config.get("CSV_EXPORT", {})
encoding = csv_export.get("encoding", "utf-8")
if isinstance(response, str):
response = response.encode(encoding)
super().__init__(response, *args, **kwargs)
```
There are no other review comments in this pull request. Would you like me
to proceed with any other changes?
**superset/views/base.py**
```
def __init__(self, response: Any = None, *args: Any, **kwargs: Any) -> None:
csv_export = app.config.get("CSV_EXPORT", {})
encoding = csv_export.get("encoding", "utf-8")
if isinstance(response, str):
response = response.encode(encoding)
super().__init__(response, *args, **kwargs)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]