mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
chore: enforce more ruff rules (#31447)
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9da65d6bfd
commit
e51b95ffa8
@@ -27,7 +27,7 @@ def test_validate_update_uniqueness(session: Session) -> None:
|
||||
|
||||
In particular, allow datasets with the same name in the same database as long as they
|
||||
are in different schemas
|
||||
"""
|
||||
""" # noqa: E501
|
||||
from superset import db
|
||||
from superset.connectors.sqla.models import SqlaTable
|
||||
from superset.models.core import Database
|
||||
|
||||
@@ -19,7 +19,7 @@ from __future__ import annotations
|
||||
|
||||
import pickle
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Generator, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING
|
||||
from uuid import UUID
|
||||
|
||||
import pytest
|
||||
@@ -54,7 +54,7 @@ NEW_VALUE = {"foo": "baz"}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def key_value_entry() -> Generator[KeyValueEntry, None, None]:
|
||||
def key_value_entry() -> KeyValueEntry:
|
||||
from superset.key_value.models import KeyValueEntry
|
||||
|
||||
entry = KeyValueEntry(
|
||||
@@ -65,7 +65,7 @@ def key_value_entry() -> Generator[KeyValueEntry, None, None]:
|
||||
)
|
||||
db.session.add(entry)
|
||||
db.session.flush()
|
||||
yield entry
|
||||
return entry
|
||||
|
||||
|
||||
def test_create_id_entry(
|
||||
@@ -143,7 +143,7 @@ def test_create_pickle_entry(
|
||||
found_entry = (
|
||||
db.session.query(KeyValueEntry).filter_by(id=created_entry.id).one()
|
||||
)
|
||||
assert isinstance(pickle.loads(found_entry.value), type(PICKLE_VALUE))
|
||||
assert isinstance(pickle.loads(found_entry.value), type(PICKLE_VALUE)) # noqa: S301
|
||||
assert found_entry.created_by_fk == admin_user.id
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ def test_user_favorite_tag(mocker):
|
||||
from superset.daos.tag import TagDAO
|
||||
|
||||
# Mock the behavior of TagDAO and g
|
||||
mock_TagDAO = mocker.patch(
|
||||
mock_TagDAO = mocker.patch( # noqa: N806
|
||||
"superset.daos.tag.TagDAO"
|
||||
) # Replace with the actual path to TagDAO
|
||||
mock_TagDAO.find_by_id.return_value = mocker.MagicMock(users_favorited=[])
|
||||
@@ -44,7 +44,7 @@ def test_remove_user_favorite_tag(mocker):
|
||||
from superset.daos.tag import TagDAO
|
||||
|
||||
# Mock the behavior of TagDAO and g
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO") # noqa: N806
|
||||
mock_tag = mocker.MagicMock(users_favorited=[])
|
||||
mock_TagDAO.find_by_id.return_value = mock_tag
|
||||
|
||||
@@ -71,7 +71,7 @@ def test_remove_user_favorite_tag_no_user(mocker):
|
||||
|
||||
# Mock the behavior of TagDAO and g
|
||||
mocker.patch("superset.daos.tag.db.session") # noqa: F841
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO") # noqa: N806
|
||||
mock_tag = mocker.MagicMock(users_favorited=[])
|
||||
mock_TagDAO.find_by_id.return_value = mock_tag
|
||||
|
||||
@@ -88,7 +88,7 @@ def test_remove_user_favorite_tag_exc_raise(mocker):
|
||||
|
||||
# Mock the behavior of TagDAO and g
|
||||
mock_session = mocker.patch("superset.daos.tag.db.session")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO") # noqa: N806
|
||||
mock_tag = mocker.MagicMock(users_favorited=[])
|
||||
mock_TagDAO.find_by_id.return_value = mock_tag
|
||||
|
||||
@@ -98,7 +98,7 @@ def test_remove_user_favorite_tag_exc_raise(mocker):
|
||||
|
||||
# Test that exception is raised when commit fails
|
||||
mock_session.commit.side_effect = Exception("DB Error")
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(Exception): # noqa: B017, PT011
|
||||
TagDAO.remove_user_favorite_tag(1)
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_user_favorite_tag_no_user(mocker):
|
||||
|
||||
# Mock the behavior of TagDAO and g
|
||||
mocker.patch("superset.daos.tag.db.session") # noqa: F841
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO") # noqa: N806
|
||||
mock_tag = mocker.MagicMock(users_favorited=[])
|
||||
mock_TagDAO.find_by_id.return_value = mock_tag
|
||||
|
||||
@@ -125,7 +125,7 @@ def test_user_favorite_tag_exc_raise(mocker):
|
||||
|
||||
# Mock the behavior of TagDAO and g
|
||||
mock_session = mocker.patch("superset.daos.tag.db.session")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO")
|
||||
mock_TagDAO = mocker.patch("superset.daos.tag.TagDAO") # noqa: N806
|
||||
mock_tag = mocker.MagicMock(users_favorited=[])
|
||||
mock_TagDAO.find_by_id.return_value = mock_tag
|
||||
|
||||
@@ -135,7 +135,7 @@ def test_user_favorite_tag_exc_raise(mocker):
|
||||
|
||||
# Test that exception is raised when commit fails
|
||||
mock_session.commit.side_effect = Exception("DB Error")
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(Exception): # noqa: B017, PT011
|
||||
TagDAO.remove_user_favorite_tag(1)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user