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: Ensure Mixins are ordered according to the MRO #26288

Merged
merged 1 commit into from
Dec 16, 2023
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
4 changes: 2 additions & 2 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def values_for_column(self, column_name: str, limit: int = 10000) -> list[Any]:
raise NotImplementedError()


class TableColumn(Model, AuditMixinNullable, ImportExportMixin, CertificationMixin):
class TableColumn(AuditMixinNullable, ImportExportMixin, CertificationMixin, Model):

"""ORM object for table columns, each table can have multiple columns"""

Expand Down Expand Up @@ -971,7 +971,7 @@ def data(self) -> dict[str, Any]:
return {s: getattr(self, s) for s in attrs if hasattr(self, s)}


class SqlMetric(Model, AuditMixinNullable, ImportExportMixin, CertificationMixin):
class SqlMetric(AuditMixinNullable, ImportExportMixin, CertificationMixin, Model):

"""ORM object for metrics, each table can have multiple metrics"""

Expand Down
6 changes: 3 additions & 3 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class DatabaseSSHTunnel(Schema):
private_key_password = fields.String(required=False)


class DatabasePostSchema(Schema, DatabaseParametersSchemaMixin):
class DatabasePostSchema(DatabaseParametersSchemaMixin, Schema):
class Meta: # pylint: disable=too-few-public-methods
unknown = EXCLUDE

Expand Down Expand Up @@ -479,7 +479,7 @@ class Meta: # pylint: disable=too-few-public-methods
ssh_tunnel = fields.Nested(DatabaseSSHTunnel, allow_none=True)


class DatabasePutSchema(Schema, DatabaseParametersSchemaMixin):
class DatabasePutSchema(DatabaseParametersSchemaMixin, Schema):
class Meta: # pylint: disable=too-few-public-methods
unknown = EXCLUDE

Expand Down Expand Up @@ -536,7 +536,7 @@ class Meta: # pylint: disable=too-few-public-methods
uuid = fields.String(required=False)


class DatabaseTestConnectionSchema(Schema, DatabaseParametersSchemaMixin):
class DatabaseTestConnectionSchema(DatabaseParametersSchemaMixin, Schema):
rename_encrypted_extra = pre_load(rename_encrypted_extra)

database_name = fields.String(
Expand Down
2 changes: 1 addition & 1 deletion superset/databases/ssh_tunnel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
app_config = current_app.config


class SSHTunnel(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
class SSHTunnel(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
"""
A ssh tunnel configuration in a database.
"""
Expand Down
2 changes: 1 addition & 1 deletion superset/datasets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
)


class Dataset(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
class Dataset(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
"""
A table/view in a database.
"""
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class ClickHouseParametersSchema(Schema):
pass


class ClickHouseConnectEngineSpec(ClickHouseEngineSpec, BasicParametersMixin):
class ClickHouseConnectEngineSpec(BasicParametersMixin, ClickHouseEngineSpec):
"""Engine spec for clickhouse-connect connector"""

engine = "clickhousedb"
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/databend.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class DatabendParametersSchema(Schema):
)


class DatabendConnectEngineSpec(DatabendEngineSpec, BasicParametersMixin):
class DatabendConnectEngineSpec(BasicParametersMixin, DatabendEngineSpec):
"""Engine spec for databend sqlalchemy connector"""

engine = "databend"
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def epoch_to_dttm(cls) -> str:
return HiveEngineSpec.epoch_to_dttm()


class DatabricksNativeEngineSpec(DatabricksODBCEngineSpec, BasicParametersMixin):
class DatabricksNativeEngineSpec(BasicParametersMixin, DatabricksODBCEngineSpec):
engine_name = "Databricks"

engine = "databricks"
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)


class MySQLEngineSpec(BaseEngineSpec, BasicParametersMixin):
class MySQLEngineSpec(BasicParametersMixin, BaseEngineSpec):
engine = "mysql"
engine_name = "MySQL"
max_column_name_length = 64
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def epoch_to_dttm(cls) -> str:
return "(timestamp 'epoch' + {col} * interval '1 second')"


class PostgresEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
class PostgresEngineSpec(BasicParametersMixin, PostgresBaseEngineSpec):
engine = "postgresql"
engine_aliases = {"postgres"}
supports_dynamic_schema = True
Expand Down
2 changes: 1 addition & 1 deletion superset/db_engine_specs/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
)


class RedshiftEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
class RedshiftEngineSpec(BasicParametersMixin, PostgresBaseEngineSpec):
engine = "redshift"
engine_name = "Amazon Redshift"
max_column_name_length = 127
Expand Down
2 changes: 1 addition & 1 deletion superset/key_value/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
VALUE_MAX_SIZE = 2**24 - 1


class KeyValueEntry(Model, AuditMixinNullable, ImportExportMixin):
class KeyValueEntry(AuditMixinNullable, ImportExportMixin, Model):
"""Key value store entity"""

__tablename__ = "key_value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def created_by(cls):
)


class Slice(Base, AuditMixin):
class Slice(AuditMixin, Base):
"""Declarative class to do query in upgrade"""

__tablename__ = "slices"
id = Column(Integer, primary_key=True)
owners = relationship("User", secondary=slice_user)


class Dashboard(Base, AuditMixin):
class Dashboard(AuditMixin, Base):
"""Declarative class to do query in upgrade"""

__tablename__ = "dashboards"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Tag(Base, AuditMixinNullable):
type = Column(Enum(TagType))


class TaggedObject(Base, AuditMixinNullable):
class TaggedObject(AuditMixinNullable, Base):
__tablename__ = "tagged_object"

id = Column(Integer, primary_key=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ImportMixin:
"slice_email_schedules",
]
models = {
table_name: type(table_name, (Base, ImportMixin), {"__tablename__": table_name})
table_name: type(table_name, (ImportMixin, Base), {"__tablename__": table_name})
for table_name in table_names
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ImportMixin:
uuid = sa.Column(UUIDType(binary=True), primary_key=False, default=uuid4)


class SavedQuery(Base, ImportMixin):
class SavedQuery(ImportMixin, Base):
__tablename__ = "saved_query"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class NewTable(AuxiliaryColumnsMixin, Base):
)


class NewDataset(Base, AuxiliaryColumnsMixin):
class NewDataset(AuxiliaryColumnsMixin, Base):
__tablename__ = "sl_datasets"

id = sa.Column(sa.Integer, primary_key=True)
Expand Down
2 changes: 1 addition & 1 deletion superset/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def copy_dashboard(_mapper: Mapper, connection: Connection, target: Dashboard) -


# pylint: disable=too-many-public-methods
class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
class Dashboard(AuditMixinNullable, ImportExportMixin, Model):
"""The dashboard object!"""

__tablename__ = "dashboards"
Expand Down
8 changes: 4 additions & 4 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


class Query(
Model, ExtraJSONMixin, ExploreMixin
ExtraJSONMixin, ExploreMixin, Model
): # pylint: disable=abstract-method,too-many-public-methods
"""ORM model for SQL query
Expand Down Expand Up @@ -355,7 +355,7 @@ def adhoc_column_to_sqla(
return self.make_sqla_column_compatible(sqla_column, label)


class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
class SavedQuery(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
"""ORM model for SQL query"""

__tablename__ = "saved_query"
Expand Down Expand Up @@ -442,7 +442,7 @@ def last_run_delta_humanized(self) -> str:
return self._last_run_delta_humanized


class TabState(Model, AuditMixinNullable, ExtraJSONMixin):
class TabState(AuditMixinNullable, ExtraJSONMixin, Model):
__tablename__ = "tab_state"

# basic info
Expand Down Expand Up @@ -505,7 +505,7 @@ def to_dict(self) -> dict[str, Any]:
}


class TableSchema(Model, AuditMixinNullable, ExtraJSONMixin):
class TableSchema(AuditMixinNullable, ExtraJSONMixin, Model):
__tablename__ = "table_schema"

id = Column(Integer, primary_key=True, autoincrement=True)
Expand Down
2 changes: 1 addition & 1 deletion superset/reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ReportSourceFormat(StrEnum):
)


class ReportSchedule(Model, AuditMixinNullable, ExtraJSONMixin):
class ReportSchedule(AuditMixinNullable, ExtraJSONMixin, Model):

"""
Report Schedules, supports alerts and reports
Expand Down
2 changes: 1 addition & 1 deletion superset/tables/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
)


class Table(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
class Table(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
"""
A table/view in a database.
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/charts/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
CHARTS_FIXTURE_COUNT = 10


class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
resource_name = "chart"

@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/dashboards/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
DASHBOARDS_FIXTURE_COUNT = 10


class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
resource_name = "dashboard"

dashboards: list[Dashboard] = []
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/profile_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .base_tests import SupersetTestCase


class TestProfile(SupersetTestCase, InsertChartMixin):
class TestProfile(InsertChartMixin, SupersetTestCase):
def insert_dashboard_created_by(self, username: str) -> Dashboard:
user = self.get_user(username)
dashboard = self.insert_dashboard(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/databases/schema_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def dummy_schema() -> "DatabaseParametersSchemaMixin":
"""
from superset.databases.schemas import DatabaseParametersSchemaMixin

class DummySchema(Schema, DatabaseParametersSchemaMixin):
class DummySchema(DatabaseParametersSchemaMixin, Schema):
sqlalchemy_uri = fields.String()

return DummySchema()
Expand Down
Loading