mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
chore: set up ruff as a new linter/formatter (#28158)
This commit is contained in:
committed by
GitHub
parent
e8a678b75a
commit
2d63722150
@@ -21,7 +21,6 @@ from sqlalchemy.engine.url import make_url
|
||||
|
||||
from superset.exceptions import SupersetSecurityException
|
||||
from superset.security.analytics_db_safety import check_sqlalchemy_uri
|
||||
from tests.integration_tests.test_app import app
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# under the License.
|
||||
# isort:skip_file
|
||||
"""Tests for security api methods"""
|
||||
|
||||
import json
|
||||
|
||||
import jwt
|
||||
@@ -29,8 +30,8 @@ from superset.utils.urls import get_url_host
|
||||
from tests.integration_tests.base_tests import SupersetTestCase
|
||||
from tests.integration_tests.constants import ADMIN_USERNAME, GAMMA_USERNAME
|
||||
from tests.integration_tests.fixtures.birth_names_dashboard import (
|
||||
load_birth_names_dashboard_with_slices,
|
||||
load_birth_names_data,
|
||||
load_birth_names_dashboard_with_slices, # noqa: F401
|
||||
load_birth_names_data, # noqa: F401
|
||||
)
|
||||
|
||||
|
||||
@@ -68,7 +69,7 @@ class TestSecurityCsrfApi(SupersetTestCase):
|
||||
|
||||
|
||||
class TestSecurityGuestTokenApi(SupersetTestCase):
|
||||
uri = f"api/v1/security/guest_token/"
|
||||
uri = "api/v1/security/guest_token/" # noqa: F541
|
||||
|
||||
def test_post_guest_token_unauthenticated(self):
|
||||
"""
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Unit tests for Superset"""
|
||||
|
||||
import json
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
@@ -26,19 +27,19 @@ from superset.connectors.sqla.models import SqlaTable
|
||||
from superset.daos.dashboard import EmbeddedDashboardDAO
|
||||
from superset.exceptions import SupersetSecurityException
|
||||
from superset.models.dashboard import Dashboard
|
||||
from superset.security.guest_token import GuestTokenResourceType
|
||||
from superset.sql_parse import Table
|
||||
from superset.security.guest_token import GuestTokenResourceType # noqa: F401
|
||||
from superset.sql_parse import Table # noqa: F401
|
||||
from superset.utils.core import get_example_default_schema
|
||||
from superset.utils.database import get_example_database
|
||||
from tests.integration_tests.base_tests import SupersetTestCase
|
||||
from tests.integration_tests.fixtures.birth_names_dashboard import (
|
||||
load_birth_names_dashboard_with_slices_class_scope,
|
||||
load_birth_names_data,
|
||||
load_birth_names_dashboard_with_slices_class_scope, # noqa: F401
|
||||
load_birth_names_data, # noqa: F401
|
||||
)
|
||||
from tests.integration_tests.fixtures.world_bank_dashboard import (
|
||||
load_world_bank_dashboard_with_slices,
|
||||
load_world_bank_dashboard_with_slices_class_scope,
|
||||
load_world_bank_data,
|
||||
load_world_bank_dashboard_with_slices, # noqa: F401
|
||||
load_world_bank_dashboard_with_slices_class_scope, # noqa: F401
|
||||
load_world_bank_data, # noqa: F401
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Unit tests for alerting in Superset"""
|
||||
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch # noqa: F401
|
||||
|
||||
import pytest
|
||||
from flask_appbuilder.security.sqla.models import Role
|
||||
|
||||
@@ -24,29 +24,29 @@ from flask import g
|
||||
import json
|
||||
import prison
|
||||
|
||||
from superset import db, security_manager, app
|
||||
from superset import db, security_manager, app # noqa: F401
|
||||
from superset.connectors.sqla.models import RowLevelSecurityFilter, SqlaTable
|
||||
from superset.security.guest_token import (
|
||||
GuestTokenResourceType,
|
||||
GuestUser,
|
||||
)
|
||||
from flask_babel import lazy_gettext as _
|
||||
from flask_babel import lazy_gettext as _ # noqa: F401
|
||||
from flask_appbuilder.models.sqla import filters
|
||||
from tests.integration_tests.base_tests import SupersetTestCase
|
||||
from tests.integration_tests.conftest import with_config
|
||||
from tests.integration_tests.conftest import with_config # noqa: F401
|
||||
from tests.integration_tests.constants import ADMIN_USERNAME
|
||||
from tests.integration_tests.fixtures.birth_names_dashboard import (
|
||||
load_birth_names_dashboard_with_slices,
|
||||
load_birth_names_data,
|
||||
load_birth_names_dashboard_with_slices, # noqa: F401
|
||||
load_birth_names_data, # noqa: F401
|
||||
)
|
||||
from tests.integration_tests.fixtures.energy_dashboard import (
|
||||
load_energy_table_with_slice,
|
||||
load_energy_table_data,
|
||||
load_energy_table_with_slice, # noqa: F401
|
||||
load_energy_table_data, # noqa: F401
|
||||
)
|
||||
from tests.integration_tests.fixtures.unicode_dashboard import (
|
||||
UNICODE_TBL_NAME,
|
||||
load_unicode_dashboard_with_slice,
|
||||
load_unicode_data,
|
||||
UNICODE_TBL_NAME, # noqa: F401
|
||||
load_unicode_dashboard_with_slice, # noqa: F401
|
||||
load_unicode_data, # noqa: F401
|
||||
)
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ class TestRowLevelSecurityUpdateAPI(SupersetTestCase):
|
||||
"roles": [roles[1].id],
|
||||
}
|
||||
rv = self.client.put(f"/api/v1/rowlevelsecurity/{rls.id}", json=payload)
|
||||
status_code, data = rv.status_code, json.loads(rv.data.decode("utf-8"))
|
||||
status_code, _data = rv.status_code, json.loads(rv.data.decode("utf-8")) # noqa: F841
|
||||
|
||||
self.assertEqual(status_code, 201)
|
||||
|
||||
@@ -608,7 +608,7 @@ class TestRowLevelSecurityWithRelatedAPI(SupersetTestCase):
|
||||
"superset.views.filters.current_app.config",
|
||||
{"EXTRA_RELATED_QUERY_FILTERS": {"role": _base_filter}},
|
||||
):
|
||||
rv = self.client.get(f"/api/v1/rowlevelsecurity/related/roles")
|
||||
rv = self.client.get("/api/v1/rowlevelsecurity/related/roles") # noqa: F541
|
||||
assert rv.status_code == 200
|
||||
response = json.loads(rv.data.decode("utf-8"))
|
||||
response_roles = [result["text"] for result in response["result"]]
|
||||
|
||||
Reference in New Issue
Block a user