Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions superset/tasks/slack_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
from io import IOBase
from typing import cast, Optional, Union

from flask import current_app
from retry.api import retry
from slack import WebClient
from slack.errors import SlackApiError
from slack.web.slack_response import SlackResponse

from superset import app

# Globals
config = app.config
logger = logging.getLogger("tasks.slack_util")


Expand All @@ -37,6 +35,7 @@ def deliver_slack_msg(
body: str,
file: Optional[Union[str, IOBase, bytes]],
) -> None:
config = current_app.config
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bycatch, the mypy commit hook was triggering on this...

client = WebClient(token=config["SLACK_API_TOKEN"], proxy=config["SLACK_PROXY"])
# files_upload returns SlackResponse as we run it in sync mode.
if file:
Expand Down
3 changes: 2 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ def query_obj(self) -> QueryObjectDict:
gb = self.groupby
metrics = self.all_metrics or []
columns = form_data.get("columns") or []
groupby = list(set(gb + columns))
# merge list and dedup while preserving order
groupby = list(OrderedDict.fromkeys(gb + columns))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, as of 3.7 key order is now officially guaranteed (already implicitly so in 3.6), so no need to use OrderedDict any more:

Suggested change
groupby = list(OrderedDict.fromkeys(gb + columns))
groupby = list(dict.fromkeys(gb + columns))

Reference: https://docs.python.org/3.7/tutorial/datastructures.html#dictionaries

Performing list(d) on a dictionary returns a list of all the keys used in the dictionary, in insertion order

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, I remember reading about how ordering is guaranteed in py3.


is_timeseries = self.is_timeseries
if DTTM_ALIAS in groupby:
Expand Down