chore: enforce more ruff rules (#31447)

Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
Maxime Beauchemin
2024-12-18 17:41:34 -08:00
committed by GitHub
parent 9da65d6bfd
commit e51b95ffa8
375 changed files with 1821 additions and 1718 deletions

View File

@@ -81,7 +81,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
"slug": "slug1_changed",
"position_json": '{"b": "B"}',
"css": "css_changed",
"json_metadata": '{"refresh_frequency": 30, "timed_refresh_immune_slices": [], "expanded_slices": {}, "color_scheme": "", "label_colors": {}, "shared_label_colors": [], "map_label_colors": {}, "color_scheme_domain": [], "cross_filters_enabled": false}',
"json_metadata": '{"refresh_frequency": 30, "timed_refresh_immune_slices": [], "expanded_slices": {}, "color_scheme": "", "label_colors": {}, "shared_label_colors": [], "map_label_colors": {}, "color_scheme_domain": [], "cross_filters_enabled": false}', # noqa: E501
"published": False,
}
@@ -94,7 +94,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
"reordered": [],
}
@pytest.fixture()
@pytest.fixture
def create_dashboards(self):
with self.create_app().app_context():
dashboards = []
@@ -136,7 +136,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
db.session.delete(fav_dashboard)
db.session.commit()
@pytest.fixture()
@pytest.fixture
def create_created_by_gamma_dashboards(self):
with self.create_app().app_context():
dashboards = []
@@ -157,7 +157,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
db.session.delete(dashboard)
db.session.commit()
@pytest.fixture()
@pytest.fixture
def create_dashboard_with_report(self):
with self.create_app().app_context():
admin = self.get_user("admin")
@@ -218,7 +218,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
- ``fourth_dashboard`` is not associated with any tag
Relies on the ``create_custom_tags`` fixture for the tag creation.
"""
""" # noqa: E501
with self.create_app().app_context():
admin_user = self.get_user(ADMIN_USERNAME)
@@ -832,9 +832,9 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
assert data_by_id["count"] == data_by_name["count"], len(
expected_dashboards
)
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_dashboards)
), set(chart.id for chart in expected_dashboards) # noqa: C401
@pytest.mark.usefixtures("create_dashboards")
def test_get_current_user_favorite_status(self):
@@ -1273,7 +1273,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
"""
admin_id = self.get_user("admin").id
dashboard_count = 4
dashboard_ids = list()
dashboard_ids = list() # noqa: C408
for dashboard_name_index in range(dashboard_count):
dashboard_ids.append(
self.insert_dashboard(
@@ -1300,7 +1300,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
"""
user = self.get_user("admin")
dashboard_count = 4
dashboard_ids = list()
dashboard_ids = list() # noqa: C408
for dashboard_name_index in range(dashboard_count):
dashboard_ids.append(
self.insert_dashboard(
@@ -1434,7 +1434,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
"""
gamma_id = self.get_user("gamma").id
dashboard_count = 4
dashboard_ids = list()
dashboard_ids = list() # noqa: C408
for dashboard_name_index in range(dashboard_count):
dashboard_ids.append(
self.insert_dashboard(
@@ -1474,7 +1474,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
dashboard = self.insert_dashboard(
"title", "slug1", [user_alpha1.id], slices=[existing_slice], published=True
)
self.login(username="alpha2", password="password")
self.login(username="alpha2", password="password") # noqa: S106
uri = f"api/v1/dashboard/{dashboard.id}"
rv = self.client.delete(uri)
assert rv.status_code == 403
@@ -1499,7 +1499,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
)
dashboard_count = 4
dashboards = list()
dashboards = list() # noqa: C408
for dashboard_name_index in range(dashboard_count):
dashboards.append(
self.insert_dashboard(
@@ -1519,7 +1519,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
published=True,
)
self.login(username="alpha2", password="password")
self.login(username="alpha2", password="password") # noqa: S106
# verify we can't delete not owned dashboards
arguments = [dashboard.id for dashboard in dashboards]
@@ -2208,7 +2208,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
dashboard = self.insert_dashboard(
"title", "slug1", [user_alpha1.id], slices=[existing_slice], published=True
)
self.login(username="alpha2", password="password")
self.login(username="alpha2", password="password") # noqa: S106
dashboard_data = {"dashboard_title": "title1_changed", "slug": "slug1 changed"}
uri = f"api/v1/dashboard/{dashboard.id}"
rv = self.put_assert_metric(uri, dashboard_data, "put")
@@ -2435,27 +2435,30 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
response = json.loads(rv.data.decode("utf-8"))
assert rv.status_code == 422
assert response == {
"errors": [
{
"message": "Error importing dashboard",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"dashboards/imported_dashboard.yaml": "Dashboard already exists and `overwrite=true` was not passed",
"issue_codes": [
{
"code": 1010,
"message": (
"Issue 1010 - Superset encountered an "
"error while running a command."
),
}
],
},
}
]
}
assert (
response
== {
"errors": [
{
"message": "Error importing dashboard",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"dashboards/imported_dashboard.yaml": "Dashboard 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."
),
}
],
},
}
]
}
)
# import with overwrite flag
buf = self.create_dashboard_import()
@@ -3021,7 +3024,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
return self.client.post(uri, json=payload)
def _get_screenshot(self, dashboard_id, cache_key, download_format):
uri = f"/api/v1/dashboard/{dashboard_id}/screenshot/{cache_key}/?download_format={download_format}"
uri = f"/api/v1/dashboard/{dashboard_id}/screenshot/{cache_key}/?download_format={download_format}" # noqa: E501
return self.client.get(uri)
@pytest.mark.usefixtures("create_dashboard_with_tag")
@@ -3240,7 +3243,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
def test_put_dashboard_colors_no_mark_updated(self):
"""
Dashboard API: Test updating dashboard colors without marking the dashboard as updated
"""
""" # noqa: E501
self.login(ADMIN_USERNAME)
dashboard = Dashboard.get("world_health")