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

@@ -148,7 +148,7 @@ def test_password_mask(
"project_id": "black-sanctum-314419",
"private_key_id": "259b0d419a8f840056158763ff54d8b08f7b8173",
"private_key": "SECRET",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com", # noqa: E501
"client_id": "114567578578109757129",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
@@ -204,7 +204,7 @@ def test_database_connection(
"project_id": "black-sanctum-314419",
"private_key_id": "259b0d419a8f840056158763ff54d8b08f7b8173",
"private_key": "SECRET",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com", # noqa: E501
"client_id": "114567578578109757129",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
@@ -242,7 +242,7 @@ def test_database_connection(
"supports_oauth2": True,
},
"expose_in_sqllab": True,
"extra": '{\n "metadata_params": {},\n "engine_params": {},\n "metadata_cache_timeout": {},\n "schemas_allowed_for_file_upload": []\n}\n',
"extra": '{\n "metadata_params": {},\n "engine_params": {},\n "metadata_cache_timeout": {},\n "schemas_allowed_for_file_upload": []\n}\n', # noqa: E501
"force_ctas_schema": None,
"id": 1,
"impersonate_user": False,
@@ -254,7 +254,7 @@ def test_database_connection(
"project_id": "black-sanctum-314419",
"private_key_id": "259b0d419a8f840056158763ff54d8b08f7b8173",
"private_key": "XXXXXXXXXX",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com", # noqa: E501
"client_id": "114567578578109757129",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
@@ -267,7 +267,7 @@ def test_database_connection(
"service_account_info": {
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com", # noqa: E501
"client_id": "114567578578109757129",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/google-spreadsheets-demo-servi%40black-sanctum-314419.iam.gserviceaccount.com",
"private_key": "XXXXXXXXXX",
@@ -373,7 +373,7 @@ def test_update_with_password_mask(
database = db.session.query(Database).one()
assert (
database.encrypted_extra
== '{"service_account_info": {"project_id": "yellow-unicorn-314419", "private_key": "SECRET"}}'
== '{"service_account_info": {"project_id": "yellow-unicorn-314419", "private_key": "SECRET"}}' # noqa: E501
)
@@ -401,7 +401,7 @@ def test_non_zip_import(client: Any, full_api_access: None) -> None:
"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
}
]
},
@@ -442,7 +442,7 @@ def test_delete_ssh_tunnel(
"project_id": "black-sanctum-314419",
"private_key_id": "259b0d419a8f840056158763ff54d8b08f7b8173",
"private_key": "SECRET",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com", # noqa: E501
"client_id": "SSH_TUNNEL_CREDENTIALS_CLIENT",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
@@ -520,7 +520,7 @@ def test_delete_ssh_tunnel_not_found(
"project_id": "black-sanctum-314419",
"private_key_id": "259b0d419a8f840056158763ff54d8b08f7b8173",
"private_key": "SECRET",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com",
"client_email": "google-spreadsheets-demo-servi@black-sanctum-314419.iam.gserviceaccount.com", # noqa: E501
"client_id": "SSH_TUNNEL_CREDENTIALS_CLIENT",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
@@ -723,9 +723,9 @@ def test_oauth2_happy_path(
token = db.session.query(DatabaseUserOAuth2Tokens).one()
assert token.user_id == 1
assert token.database_id == 1
assert token.access_token == "YYY"
assert token.access_token == "YYY" # noqa: S105
assert token.access_token_expiration == datetime(2024, 1, 1, 1, 0)
assert token.refresh_token == "ZZZ"
assert token.refresh_token == "ZZZ" # noqa: S105
def test_oauth2_multiple_tokens(
@@ -804,8 +804,8 @@ def test_oauth2_multiple_tokens(
tokens = db.session.query(DatabaseUserOAuth2Tokens).all()
assert len(tokens) == 1
token = tokens[0]
assert token.access_token == "YYY2"
assert token.refresh_token == "ZZZ2"
assert token.access_token == "YYY2" # noqa: S105
assert token.refresh_token == "ZZZ2" # noqa: S105
def test_oauth2_error(
@@ -1811,7 +1811,7 @@ def test_table_metadata_no_table(
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
"message": "Issue 1020 - The submitted payload has the incorrect schema.", # noqa: E501
}
],
},
@@ -1862,7 +1862,7 @@ def test_table_metadata_invalid_database(
"issue_codes": [
{
"code": 1011,
"message": "Issue 1011 - Superset encountered an unexpected error.",
"message": "Issue 1011 - Superset encountered an unexpected error.", # noqa: E501
},
{
"code": 1036,
@@ -1975,7 +1975,7 @@ def test_table_extra_metadata_no_table(
"issue_codes": [
{
"code": 1020,
"message": "Issue 1020 - The submitted payload has the incorrect schema.",
"message": "Issue 1020 - The submitted payload has the incorrect schema.", # noqa: E501
}
],
},
@@ -2026,7 +2026,7 @@ def test_table_extra_metadata_invalid_database(
"issue_codes": [
{
"code": 1011,
"message": "Issue 1011 - Superset encountered an unexpected error.",
"message": "Issue 1011 - Superset encountered an unexpected error.", # noqa: E501
},
{
"code": 1036,
@@ -2084,7 +2084,7 @@ def test_catalogs(
"""
database = mocker.MagicMock()
database.get_all_catalog_names.return_value = {"db1", "db2"}
DatabaseDAO = mocker.patch("superset.databases.api.DatabaseDAO")
DatabaseDAO = mocker.patch("superset.databases.api.DatabaseDAO") # noqa: N806
DatabaseDAO.find_by_id.return_value = database
security_manager = mocker.patch(
@@ -2128,7 +2128,7 @@ def test_catalogs_with_oauth2(
"tab_id",
"redirect_uri",
)
DatabaseDAO = mocker.patch("superset.databases.api.DatabaseDAO")
DatabaseDAO = mocker.patch("superset.databases.api.DatabaseDAO") # noqa: N806
DatabaseDAO.find_by_id.return_value = database
security_manager = mocker.patch(