You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/08/17 20:49:47 UTC
[superset] branch rename_get_iterable updated: Small fixes
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch rename_get_iterable
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/rename_get_iterable by this push:
new 2a8643982c Small fixes
2a8643982c is described below
commit 2a8643982c5f251a09aea9391037e9ce1168d2b1
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Aug 17 13:49:36 2023 -0700
Small fixes
---
superset/daos/base.py | 8 ++++----
superset/daos/chart.py | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/superset/daos/base.py b/superset/daos/base.py
index 0bd0d76ead..a69f07da5d 100644
--- a/superset/daos/base.py
+++ b/superset/daos/base.py
@@ -16,7 +16,7 @@
# under the License.
from __future__ import annotations
-from typing import Any, Generic, get_args, TypeVar
+from typing import Any, cast, Generic, get_args, TypeVar
from flask_appbuilder.models.filters import BaseFilter
from flask_appbuilder.models.sqla import Model
@@ -197,7 +197,7 @@ class BaseDAO(Generic[T]):
return item # type: ignore
@classmethod
- def delete(cls, items: T | list[T], commit: bool = True) -> None:
+ def delete(cls, item_or_items: T | list[T], commit: bool = True) -> None:
"""
Delete the specified item(s) including their associated relationships.
@@ -214,9 +214,9 @@ class BaseDAO(Generic[T]):
:raises DAODeleteFailedError: If the deletion failed
:see: https://docs.sqlalchemy.org/en/latest/orm/queryguide/dml.html
"""
-
+ items = cast(list[T], as_list(item_or_items))
try:
- for item in as_list(items):
+ for item in items:
db.session.delete(item)
if commit:
diff --git a/superset/daos/chart.py b/superset/daos/chart.py
index 463ec9a3b3..8bed30014c 100644
--- a/superset/daos/chart.py
+++ b/superset/daos/chart.py
@@ -40,7 +40,7 @@ class ChartDAO(BaseDAO[Slice]):
@classmethod
def delete(cls, item_or_items: Slice | list[Slice], commit: bool = True) -> None:
- items = cast(list[Slice], item_or_items)
+ items = cast(list[Slice], as_list(item_or_items))
item_ids = [item.id for item in items]
# bulk delete, first delete related data
# bulk delete itself