mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +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
@@ -93,7 +93,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
cache_manager.data_cache.clear()
|
||||
yield
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def create_charts(self):
|
||||
with self.create_app().app_context():
|
||||
charts = []
|
||||
@@ -117,7 +117,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
db.session.delete(fav_chart)
|
||||
db.session.commit()
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def create_charts_created_by_gamma(self):
|
||||
with self.create_app().app_context():
|
||||
charts = []
|
||||
@@ -130,7 +130,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
db.session.delete(chart)
|
||||
db.session.commit()
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def create_certified_charts(self):
|
||||
with self.create_app().app_context():
|
||||
certified_charts = []
|
||||
@@ -153,7 +153,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
db.session.delete(chart)
|
||||
db.session.commit()
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def create_chart_with_report(self):
|
||||
with self.create_app().app_context():
|
||||
admin = self.get_user("admin")
|
||||
@@ -173,7 +173,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
db.session.delete(chart)
|
||||
db.session.commit()
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def add_dashboard_to_chart(self):
|
||||
with self.create_app().app_context():
|
||||
admin = self.get_user("admin")
|
||||
@@ -348,7 +348,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
"""
|
||||
admin = self.get_user("admin")
|
||||
chart_count = 4
|
||||
chart_ids = list()
|
||||
chart_ids = list() # noqa: C408
|
||||
for chart_name_index in range(chart_count):
|
||||
chart_ids.append(
|
||||
self.insert_chart(f"title{chart_name_index}", [admin.id], 1, admin).id
|
||||
@@ -462,7 +462,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
"""
|
||||
gamma_id = self.get_user("gamma").id
|
||||
chart_count = 4
|
||||
chart_ids = list()
|
||||
chart_ids = list() # noqa: C408
|
||||
for chart_name_index in range(chart_count):
|
||||
chart_ids.append(
|
||||
self.insert_chart(f"title{chart_name_index}", [gamma_id], 1).id
|
||||
@@ -492,7 +492,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
"alpha2", "password", "Alpha", email="alpha2@superset.org"
|
||||
)
|
||||
chart = self.insert_chart("title", [user_alpha1.id], 1)
|
||||
self.login(username="alpha2", password="password")
|
||||
self.login(username="alpha2", password="password") # noqa: S106
|
||||
uri = f"api/v1/chart/{chart.id}"
|
||||
rv = self.delete_assert_metric(uri, "delete")
|
||||
assert rv.status_code == 403
|
||||
@@ -513,7 +513,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
)
|
||||
|
||||
chart_count = 4
|
||||
charts = list()
|
||||
charts = list() # noqa: C408
|
||||
for chart_name_index in range(chart_count):
|
||||
charts.append(
|
||||
self.insert_chart(f"title{chart_name_index}", [user_alpha1.id], 1)
|
||||
@@ -521,7 +521,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
|
||||
owned_chart = self.insert_chart("title_owned", [user_alpha2.id], 1)
|
||||
|
||||
self.login(username="alpha2", password="password")
|
||||
self.login(username="alpha2", password="password") # noqa: S106
|
||||
|
||||
# verify we can't delete not owned charts
|
||||
arguments = [chart.id for chart in charts]
|
||||
@@ -922,7 +922,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
)
|
||||
chart = self.insert_chart("title", [user_alpha1.id], 1)
|
||||
|
||||
self.login(username="alpha2", password="password")
|
||||
self.login(username="alpha2", password="password") # noqa: S106
|
||||
chart_data = {"slice_name": "title1_changed"}
|
||||
uri = f"api/v1/chart/{chart.id}"
|
||||
rv = self.put_assert_metric(uri, chart_data, "put")
|
||||
@@ -960,7 +960,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
new_dashboard.published = False
|
||||
db.session.add(new_dashboard)
|
||||
|
||||
self.login(username="alpha1", password="password")
|
||||
self.login(username="alpha1", password="password") # noqa: S106
|
||||
chart_data_with_invalid_dashboard = {
|
||||
"slice_name": "title1_changed",
|
||||
"dashboards": [original_dashboard.id, 0],
|
||||
@@ -1208,9 +1208,9 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
|
||||
# Compare results
|
||||
assert data_by_id["count"] == data_by_name["count"], len(expected_charts)
|
||||
assert set(chart["id"] for chart in data_by_id["result"]) == set(
|
||||
assert set(chart["id"] for chart in data_by_id["result"]) == set( # noqa: C401
|
||||
chart["id"] for chart in data_by_name["result"]
|
||||
), set(chart.id for chart in expected_charts)
|
||||
), set(chart.id for chart in expected_charts) # noqa: C401
|
||||
|
||||
def test_get_charts_changed_on(self):
|
||||
"""
|
||||
@@ -1255,7 +1255,7 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
data = json.loads(rv.data.decode("utf-8"))
|
||||
assert data["count"] == 5
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def load_energy_charts(self):
|
||||
with app.app_context():
|
||||
admin = self.get_user("admin")
|
||||
@@ -1824,11 +1824,11 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
"error_type": "GENERIC_COMMAND_ERROR",
|
||||
"level": "warning",
|
||||
"extra": {
|
||||
"charts/imported_chart.yaml": "Chart already exists and `overwrite=true` was not passed",
|
||||
"charts/imported_chart.yaml": "Chart already exists and `overwrite=true` was not passed", # noqa: E501
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1010,
|
||||
"message": "Issue 1010 - Superset encountered an error while running a command.",
|
||||
"message": "Issue 1010 - Superset encountered an error while running a command.", # noqa: E501
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -2383,4 +2383,4 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
|
||||
data = json.loads(rv.data.decode("utf-8"))
|
||||
result = data["result"]
|
||||
excluded_key = "query"
|
||||
assert all([excluded_key not in query for query in result])
|
||||
assert all([excluded_key not in query for query in result]) # noqa: C419
|
||||
|
||||
Reference in New Issue
Block a user