Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable ruff's isort equivalent #28267

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ exclude = [
"venv",
]


# Same as Black.
line-length = 88
indent-width = 4
Expand All @@ -438,13 +439,31 @@ target-version = "py310"
select = ["E4", "E7", "E9", "F"]
ignore = []

extend-select = ["I"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.lint.isort]
case-sensitive = false
combine-as-imports = true
force-sort-within-sections = false
known-first-party = []
known-third-party = []
lines-after-imports = -1
order-by-type = false
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"local-folder"
]

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
Expand Down
2 changes: 1 addition & 1 deletion superset/async_events/async_query_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import jwt
import redis
from flask import Flask, request, Request, Response, session
from flask import Flask, Request, request, Response, session

from superset.utils.core import get_user_id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
import json # noqa: E402

from alembic import op # noqa: E402
from sqlalchemy import Column, create_engine, ForeignKey, Integer, String, Text # noqa: E402
from sqlalchemy import ( # noqa: E402
Column,
create_engine,
ForeignKey,
Integer,
String,
Text,
)
from sqlalchemy.ext.declarative import declarative_base # noqa: E402

from superset import db # noqa: E402
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from sqlalchemy.dialects.postgresql.base import PGDialect # noqa: E402
from sqlalchemy.dialects.sqlite.base import SQLiteDialect # noqa: E402


report_schedule = sa.Table(
"report_schedule",
sa.MetaData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
from sqlalchemy_utils import UUIDType # noqa: E402

from superset.connectors.sqla.models import ADDITIVE_METRIC_TYPES_LOWER # noqa: E402
from superset.connectors.sqla.utils import get_dialect_name, get_identifier_quoter # noqa: E402
from superset.connectors.sqla.utils import ( # noqa: E402
get_dialect_name,
get_identifier_quoter,
)
from superset.extensions import encrypted_field_factory # noqa: E402
from superset.migrations.shared.utils import assign_uuids # noqa: E402
from superset.sql_parse import extract_table_references, Table # noqa: E402
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
from alembic import op

from superset import db
from superset.migrations.shared.migrate_viz.processors import (
MigrateDualLine, # noqa: E402
)

# revision identifiers, used by Alembic.
revision = "ae58e1e58e5c"
down_revision = "4c5da39be729"

from superset.migrations.shared.migrate_viz.processors import MigrateDualLine # noqa: E402


def upgrade():
bind = op.get_bind()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
from sqlalchemy.ext.declarative import declarative_base # noqa: E402

from superset import db # noqa: E402
from superset.migrations.shared.utils import paginated_update, table_has_column # noqa: E402
from superset.migrations.shared.utils import ( # noqa: E402
paginated_update,
table_has_column,
)

Base = declarative_base()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from importlib import import_module # noqa: E402


module = import_module(
"superset.migrations.versions.2023-09-06_13-18_317970b4400c_added_time_secondary_column_to_"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from importlib import import_module # noqa: E402


module = import_module(
"superset.migrations.versions.2021-03-29_11-15_3ebe0993c770_filterset_table"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/common/logger_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
isclass,
isfunction,
ismethod,
signature,
Signature,
signature,
)
from logging import Logger
from typing import Any, Callable, cast, Union
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/dashboards/filter_state/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
from sqlalchemy.orm import Session # noqa: F401

from superset import db
from superset.commands.dashboard.exceptions import DashboardAccessDeniedError # noqa: F401
from superset.commands.dashboard.exceptions import (
DashboardAccessDeniedError, # noqa: F401
)
from superset.commands.temporary_cache.entry import Entry
from superset.extensions import cache_manager
from superset.models.dashboard import Dashboard
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/dashboards/permalink/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
from sqlalchemy.orm import Session # noqa: F401

from superset import db
from superset.commands.dashboard.exceptions import DashboardAccessDeniedError # noqa: F401
from superset.commands.dashboard.exceptions import (
DashboardAccessDeniedError, # noqa: F401
)
from superset.key_value.models import KeyValueEntry
from superset.key_value.types import KeyValueResource
from superset.key_value.utils import decode_permalink_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
load_birth_names_dashboard_with_slices, # noqa: F401
load_birth_names_data, # noqa: F401
)
from tests.integration_tests.fixtures.public_role import public_role_like_gamma # noqa: F401
from tests.integration_tests.fixtures.public_role import (
public_role_like_gamma, # noqa: F401
)
from tests.integration_tests.fixtures.query_context import get_query_context
from tests.integration_tests.fixtures.world_bank_dashboard import (
load_world_bank_dashboard_with_slices, # noqa: F401
Expand Down
5 changes: 4 additions & 1 deletion tests/integration_tests/datasets/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
from superset.utils.database import get_example_database, get_main_database
from superset.utils.dict_import_export import export_to_dict
from tests.integration_tests.base_tests import SupersetTestCase
from tests.integration_tests.conftest import CTAS_SCHEMA_NAME, with_feature_flags # noqa: F401
from tests.integration_tests.conftest import ( # noqa: F401
CTAS_SCHEMA_NAME,
with_feature_flags,
)
from tests.integration_tests.constants import (
ADMIN_USERNAME,
ALPHA_USERNAME,
Expand Down
11 changes: 9 additions & 2 deletions tests/integration_tests/datasource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@
from superset import app, db
from superset.commands.dataset.exceptions import DatasetNotFoundError
from superset.common.utils.query_cache_manager import QueryCacheManager
from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn # noqa: F401
from superset.connectors.sqla.models import ( # noqa: F401
SqlaTable,
SqlMetric,
TableColumn,
)
from superset.constants import CacheRegion
from superset.daos.exceptions import DatasourceNotFound, DatasourceTypeNotSupportedError
from superset.exceptions import SupersetGenericDBErrorException
from superset.models.core import Database
from superset.utils.core import backend, get_example_default_schema # noqa: F401
from superset.utils.database import get_example_database, get_main_database # noqa: F401
from superset.utils.database import ( # noqa: F401
get_example_database,
get_main_database,
)
from tests.integration_tests.base_tests import db_insert_temp_object, SupersetTestCase
from tests.integration_tests.constants import ADMIN_USERNAME
from tests.integration_tests.fixtures.birth_names_dashboard import (
Expand Down
10 changes: 8 additions & 2 deletions tests/integration_tests/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
load_birth_names_dashboard_with_slices, # noqa: F401
load_birth_names_dashboard_with_slices_module_scope, # noqa: F401
)
from .energy_dashboard import load_energy_table_data, load_energy_table_with_slice # noqa: F401
from .public_role import public_role_like_gamma, public_role_like_test_role # noqa: F401
from .energy_dashboard import ( # noqa: F401
load_energy_table_data,
load_energy_table_with_slice,
)
from .public_role import ( # noqa: F401
public_role_like_gamma,
public_role_like_test_role,
)
from .unicode_dashboard import (
load_unicode_dashboard_with_position, # noqa: F401
load_unicode_dashboard_with_slice, # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
ReportRecipientType,
ReportScheduleType,
)
from tests.integration_tests.fixtures.tabbed_dashboard import tabbed_dashboard # noqa: F401
from tests.integration_tests.fixtures.tabbed_dashboard import (
tabbed_dashboard, # noqa: F401
)

DASHBOARD_REPORT_SCHEDULE_DEFAULTS = {
"type": ReportScheduleType.REPORT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
from superset.commands.report.execute import AsyncExecuteReportScheduleCommand
from superset.models.dashboard import Dashboard
from superset.reports.models import ReportSourceFormat
from tests.integration_tests.fixtures.tabbed_dashboard import tabbed_dashboard # noqa: F401
from tests.integration_tests.fixtures.tabbed_dashboard import (
tabbed_dashboard, # noqa: F401
)
from tests.integration_tests.reports.utils import create_dashboard_report


Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/tagging_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
from superset.utils.database import get_main_database
from tests.integration_tests.base_tests import SupersetTestCase
from tests.integration_tests.conftest import with_feature_flags
from tests.integration_tests.fixtures.tags import with_tagging_system_feature # noqa: F401
from tests.integration_tests.fixtures.tags import (
with_tagging_system_feature, # noqa: F401
)


class TestTagging(SupersetTestCase):
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/tags/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
dataset_config, # noqa: F401
dataset_metadata_config, # noqa: F401
)
from tests.integration_tests.fixtures.tags import with_tagging_system_feature # noqa: F401
from tests.integration_tests.fixtures.tags import (
with_tagging_system_feature, # noqa: F401
)
from tests.integration_tests.fixtures.world_bank_dashboard import (
load_world_bank_dashboard_with_slices, # noqa: F401
load_world_bank_data, # noqa: F401
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/tasks/async_queries_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
load_birth_names_data, # noqa: F401
)
from tests.integration_tests.fixtures.query_context import get_query_context
from tests.integration_tests.fixtures.tags import with_tagging_system_feature # noqa: F401
from tests.integration_tests.fixtures.tags import (
with_tagging_system_feature, # noqa: F401
)
from tests.integration_tests.test_app import app


Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/commands/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from unittest.mock import MagicMock, patch


from superset.commands.utils import compute_owner_list, populate_owner_list, User


Expand Down
Loading