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

@@ -192,7 +192,7 @@ class TestExportDatasetsCommand(SupersetTestCase):
example_dataset = example_db.tables[0]
command = ExportDatasetsCommand([example_dataset.id])
contents = command.run()
with self.assertRaises(DatasetNotFoundError):
with self.assertRaises(DatasetNotFoundError): # noqa: PT027
next(contents)
@patch("superset.security.manager.g")
@@ -201,7 +201,7 @@ class TestExportDatasetsCommand(SupersetTestCase):
mock_g.user = security_manager.find_user("admin")
command = ExportDatasetsCommand([-1])
contents = command.run()
with self.assertRaises(DatasetNotFoundError):
with self.assertRaises(DatasetNotFoundError): # noqa: PT027
next(contents)
@patch("superset.security.manager.g")
@@ -282,7 +282,7 @@ class TestImportDatasetsCommand(SupersetTestCase):
)
assert (
dataset.params
== '{"remote_id": 3, "database_name": "examples", "import_time": 1604342885}'
== '{"remote_id": 3, "database_name": "examples", "import_time": 1604342885}' # noqa: E501
)
assert len(dataset.metrics) == 2
assert dataset.main_dttm_col == "ds"
@@ -322,7 +322,7 @@ class TestImportDatasetsCommand(SupersetTestCase):
)
assert (
dataset.params
== '{"remote_id": 3, "database_name": "examples", "import_time": 1604342885}'
== '{"remote_id": 3, "database_name": "examples", "import_time": 1604342885}' # noqa: E501
)
assert len(dataset.metrics) == 2
assert dataset.main_dttm_col == "ds"
@@ -373,7 +373,7 @@ class TestImportDatasetsCommand(SupersetTestCase):
assert dataset.fetch_values_predicate is None
assert (
dataset.extra
== '{"certification": {"certified_by": "Data Platform Team", "details": "This table is the source of truth."}, "warning_markdown": "This is a warning."}'
== '{"certification": {"certified_by": "Data Platform Team", "details": "This table is the source of truth."}, "warning_markdown": "This is a warning."}' # noqa: E501
)
# user should be included as one of the owners
@@ -554,7 +554,7 @@ class TestCreateDatasetCommand(SupersetTestCase):
@patch("superset.commands.utils.g")
def test_database_not_found(self, mock_g):
mock_g.user = security_manager.find_user("admin")
with self.assertRaises(DatasetInvalidError):
with self.assertRaises(DatasetInvalidError): # noqa: PT027
CreateDatasetCommand({"table_name": "table", "database": 9999}).run()
@patch("superset.commands.utils.g")
@@ -562,7 +562,7 @@ class TestCreateDatasetCommand(SupersetTestCase):
def test_get_table_from_database_error(self, get_table_mock, mock_g):
get_table_mock.side_effect = SQLAlchemyError
mock_g.user = security_manager.find_user("admin")
with self.assertRaises(DatasetInvalidError):
with self.assertRaises(DatasetInvalidError): # noqa: PT027
CreateDatasetCommand(
{"table_name": "table", "database": get_example_database().id}
).run()
@@ -598,7 +598,7 @@ class TestCreateDatasetCommand(SupersetTestCase):
def test_create_dataset_command_not_allowed(self):
examples_db = get_example_database()
with override_user(security_manager.find_user("gamma")):
with self.assertRaises(DatasetInvalidError):
with self.assertRaises(DatasetInvalidError): # noqa: PT027
_ = CreateDatasetCommand(
{
"sql": "select * from ab_user",
@@ -610,7 +610,7 @@ class TestCreateDatasetCommand(SupersetTestCase):
class TestDatasetWarmUpCacheCommand(SupersetTestCase):
def test_warm_up_cache_command_table_not_found(self):
with self.assertRaises(WarmUpCacheTableNotFoundError):
with self.assertRaises(WarmUpCacheTableNotFoundError): # noqa: PT027
DatasetWarmUpCacheCommand("not", "here", None, None).run()
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")