Skip to content

Commit

Permalink
chore: remove unused functions in utils/core (apache#25912)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianliebscher authored and sfirke committed Mar 22, 2024
1 parent 4fa64ad commit bd1fb0f
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import sqlalchemy as sa
from cryptography.hazmat.backends import default_backend
from cryptography.x509 import Certificate, load_pem_x509_certificate
from flask import current_app, flash, g, Markup, request
from flask import current_app, g, Markup, request
from flask_appbuilder import SQLA
from flask_appbuilder.security.sqla.models import User
from flask_babel import gettext as __
Expand Down Expand Up @@ -354,17 +354,6 @@ class ColumnSpec(NamedTuple):
python_date_format: str | None = None


def flasher(msg: str, severity: str = "message") -> None:
"""Flask's flash if available, logging call if not"""
try:
flash(msg, severity)
except RuntimeError:
if severity == "danger":
logger.error(msg, exc_info=True)
else:
logger.info(msg)


def parse_js_uri_path_item(
item: str | None, unquote: bool = True, eval_undefined: bool = False
) -> str | None:
Expand Down Expand Up @@ -448,15 +437,6 @@ def cast_to_boolean(value: Any) -> bool | None:
return False


def list_minus(l: list[Any], minus: list[Any]) -> list[Any]:
"""Returns l without what is in minus
>>> list_minus([1, 2, 3], [2])
[1, 3]
"""
return [o for o in l if o not in minus]


class DashboardEncoder(json.JSONEncoder):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -995,13 +975,6 @@ def get_email_address_list(address_string: str) -> list[str]:
return [x.strip() for x in address_string_list if x.strip()]


def get_email_address_str(address_string: str) -> str:
address_list = get_email_address_list(address_string)
address_list_str = ", ".join(address_list)

return address_list_str


def choicify(values: Iterable[Any]) -> list[tuple[Any, Any]]:
"""Takes an iterable and makes an iterable of tuples with it"""
return [(v, v) for v in values]
Expand Down Expand Up @@ -1701,15 +1674,6 @@ def extract_column_dtype(col: BaseColumn) -> GenericDataType:
return GenericDataType.STRING


def indexed(items: list[Any], key: str | Callable[[Any], Any]) -> dict[Any, list[Any]]:
"""Build an index for a list of objects"""
idx: dict[Any, Any] = {}
for item in items:
key_ = getattr(item, key) if isinstance(key, str) else key(item)
idx.setdefault(key_, []).append(item)
return idx


def is_test() -> bool:
return parse_boolean_string(os.environ.get("SUPERSET_TESTENV", "false"))

Expand Down

0 comments on commit bd1fb0f

Please sign in to comment.