Skip to content

Commit

Permalink
Fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Mar 17, 2023
1 parent d1a3fb9 commit 2f756c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions superset/charts/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import logging
from typing import Optional
from typing import cast, Optional

from flask_appbuilder.models.sqla import Model
from flask_babel import lazy_gettext as _
Expand Down Expand Up @@ -45,9 +45,10 @@ def __init__(self, model_id: int):

def run(self) -> Model:
self.validate()
self._model = cast(Slice, self._model)
try:
Dashboard.clear_cache_for_slice(slice_id=self._model_id)
# Even thought SQLAlchemy should in theory delete rows from the association
# Even though SQLAlchemy should in theory delete rows from the association
# table, sporadically Superset will error because the rows are not deleted.
# Let's do it manually here to prevent the error.
self._model.owners = []
Expand Down
5 changes: 3 additions & 2 deletions superset/datasets/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import logging
from typing import Optional
from typing import cast, Optional

from flask_appbuilder.models.sqla import Model
from sqlalchemy.exc import SQLAlchemyError
Expand Down Expand Up @@ -43,8 +43,9 @@ def __init__(self, model_id: int):

def run(self) -> Model:
self.validate()
self._model = cast(SqlaTable, self._model)
try:
# Even thought SQLAlchemy should in theory delete rows from the association
# Even though SQLAlchemy should in theory delete rows from the association
# table, sporadically Superset will error because the rows are not deleted.
# Let's do it manually here to prevent the error.
self._model.owners = []
Expand Down

0 comments on commit 2f756c7

Please sign in to comment.