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

@@ -197,7 +197,7 @@ class TestSqlLabApi(SupersetTestCase):
"Dummy Role",
email="unauth_user1@superset.org", # noqa: F541
)
self.login(username="unauth_user1", password="password")
self.login(username="unauth_user1", password="password") # noqa: S106
rv = self.client.get("/api/v1/sqllab/")
assert rv.status_code == 403
@@ -361,7 +361,7 @@ class TestSqlLabApi(SupersetTestCase):
sql_lab_mock.return_value = resp
dbobj = self.create_fake_db_for_macros()
json_payload = dict(database_id=dbobj.id, sql=sql)
json_payload = dict(database_id=dbobj.id, sql=sql) # noqa: C408
self.get_json_resp(
"/api/v1/sqllab/execute/", raise_on_error=False, json_=json_payload
)
@@ -424,7 +424,7 @@ class TestSqlLabApi(SupersetTestCase):
app.config["RESULTS_BACKEND_USE_MSGPACK"] = use_msgpack
@mock.patch("superset.models.sql_lab.Query.raise_for_access", lambda _: None)
@mock.patch("superset.models.sql_lab.Query.raise_for_access", lambda _: None) # noqa: PT008
@mock.patch("superset.models.core.Database.get_df")
def test_export_results(self, get_df_mock: mock.Mock) -> None:
self.login(ADMIN_USERNAME)

View File

@@ -86,10 +86,13 @@ class TestQueryEstimationCommand(SupersetTestCase):
assert (
ex_info.value.error.error_type == SupersetErrorType.SQLLAB_TIMEOUT_ERROR
)
assert ex_info.value.error.message == __(
"The query estimation was killed after %(sqllab_timeout)s seconds. It might "
"be too complex, or the database might be under heavy load.",
sqllab_timeout=app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
assert (
ex_info.value.error.message
== __(
"The query estimation was killed after %(sqllab_timeout)s seconds. It might " # noqa: E501
"be too complex, or the database might be under heavy load.",
sqllab_timeout=app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
)
)
def test_run_success(self) -> None:
@@ -112,7 +115,7 @@ class TestQueryEstimationCommand(SupersetTestCase):
class TestSqlResultExportCommand(SupersetTestCase):
@pytest.fixture()
@pytest.fixture
def create_database_and_query(self):
with self.create_app().app_context():
database = get_example_database()
@@ -246,7 +249,7 @@ class TestSqlResultExportCommand(SupersetTestCase):
class TestSqlExecutionResultsCommand(SupersetTestCase):
@pytest.fixture()
@pytest.fixture
def create_database_and_query(self):
with self.create_app().app_context():
database = get_example_database()
@@ -335,7 +338,7 @@ class TestSqlExecutionResultsCommand(SupersetTestCase):
"superset.views.utils._deserialize_results_payload",
side_effect=SerializationError(),
):
with pytest.raises(SupersetErrorException) as ex_info:
with pytest.raises(SupersetErrorException) as ex_info: # noqa: PT012
command = results.SqlExecutionResultsCommand("test_other", 1000)
command.run()
assert (

View File

@@ -31,7 +31,7 @@ def test_non_async_execute(non_async_example_db: Database, example_query: Query)
return_results=True,
start_time=now_as_float(),
expand_data=True,
log_params=dict(),
log_params=dict(), # noqa: C408
)
assert result
assert result["query_id"] == example_query.id