You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jo...@apache.org on 2023/12/16 01:12:04 UTC

(superset) branch master updated: chore: Ensure Mixins are ordered according to the MRO (#26288)

This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new aafb54d042 chore: Ensure Mixins are ordered according to the MRO (#26288)
aafb54d042 is described below

commit aafb54d042513d4f3c4ed8df85e2c5d1cd05c11e
Author: John Bodley <45...@users.noreply.github.com>
AuthorDate: Sat Dec 16 14:11:58 2023 +1300

    chore: Ensure Mixins are ordered according to the MRO (#26288)
---
 superset/connectors/sqla/models.py                                | 4 ++--
 superset/databases/schemas.py                                     | 6 +++---
 superset/databases/ssh_tunnel/models.py                           | 2 +-
 superset/datasets/models.py                                       | 2 +-
 superset/db_engine_specs/clickhouse.py                            | 2 +-
 superset/db_engine_specs/databend.py                              | 2 +-
 superset/db_engine_specs/databricks.py                            | 2 +-
 superset/db_engine_specs/mysql.py                                 | 2 +-
 superset/db_engine_specs/postgres.py                              | 2 +-
 superset/db_engine_specs/redshift.py                              | 2 +-
 superset/key_value/models.py                                      | 2 +-
 .../versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py | 4 ++--
 .../versions/2018-07-26_11-10_c82ee8a39623_add_implicit_tags.py   | 2 +-
 ...20-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py | 2 +-
 ...0-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py | 2 +-
 .../2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py    | 2 +-
 superset/models/dashboard.py                                      | 2 +-
 superset/models/sql_lab.py                                        | 8 ++++----
 superset/reports/models.py                                        | 2 +-
 superset/tables/models.py                                         | 2 +-
 tests/integration_tests/charts/api_tests.py                       | 2 +-
 tests/integration_tests/dashboards/api_tests.py                   | 2 +-
 tests/integration_tests/profile_tests.py                          | 2 +-
 tests/unit_tests/databases/schema_tests.py                        | 2 +-
 24 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 598bc6741b..55abaaf68b 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -757,7 +757,7 @@ class AnnotationDatasource(BaseDatasource):
         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"""
 
@@ -971,7 +971,7 @@ class TableColumn(Model, AuditMixinNullable, ImportExportMixin, CertificationMix
         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"""
 
diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py
index b56c98c5d6..65005824d5 100644
--- a/superset/databases/schemas.py
+++ b/superset/databases/schemas.py
@@ -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
 
@@ -479,7 +479,7 @@ class DatabasePostSchema(Schema, DatabaseParametersSchemaMixin):
     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
 
@@ -536,7 +536,7 @@ class DatabasePutSchema(Schema, DatabaseParametersSchemaMixin):
     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(
diff --git a/superset/databases/ssh_tunnel/models.py b/superset/databases/ssh_tunnel/models.py
index d9462a63db..3d1411cc80 100644
--- a/superset/databases/ssh_tunnel/models.py
+++ b/superset/databases/ssh_tunnel/models.py
@@ -34,7 +34,7 @@ from superset.models.helpers import (
 app_config = current_app.config
 
 
-class SSHTunnel(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
+class SSHTunnel(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
     """
     A ssh tunnel configuration in a database.
     """
diff --git a/superset/datasets/models.py b/superset/datasets/models.py
index 50aeea7b51..aa5d0fe72c 100644
--- a/superset/datasets/models.py
+++ b/superset/datasets/models.py
@@ -69,7 +69,7 @@ dataset_user_association_table = sa.Table(
 )
 
 
-class Dataset(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
+class Dataset(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
     """
     A table/view in a database.
     """
diff --git a/superset/db_engine_specs/clickhouse.py b/superset/db_engine_specs/clickhouse.py
index 4c5ec44d56..4346f77d64 100644
--- a/superset/db_engine_specs/clickhouse.py
+++ b/superset/db_engine_specs/clickhouse.py
@@ -248,7 +248,7 @@ except ImportError:  # ClickHouse Connect not installed, do nothing
     pass
 
 
-class ClickHouseConnectEngineSpec(ClickHouseEngineSpec, BasicParametersMixin):
+class ClickHouseConnectEngineSpec(BasicParametersMixin, ClickHouseEngineSpec):
     """Engine spec for clickhouse-connect connector"""
 
     engine = "clickhousedb"
diff --git a/superset/db_engine_specs/databend.py b/superset/db_engine_specs/databend.py
index 589e8b9168..8ad4713024 100644
--- a/superset/db_engine_specs/databend.py
+++ b/superset/db_engine_specs/databend.py
@@ -194,7 +194,7 @@ class DatabendParametersSchema(Schema):
     )
 
 
-class DatabendConnectEngineSpec(DatabendEngineSpec, BasicParametersMixin):
+class DatabendConnectEngineSpec(BasicParametersMixin, DatabendEngineSpec):
     """Engine spec for databend sqlalchemy connector"""
 
     engine = "databend"
diff --git a/superset/db_engine_specs/databricks.py b/superset/db_engine_specs/databricks.py
index 1cbf4a238d..4b2f93ca5d 100644
--- a/superset/db_engine_specs/databricks.py
+++ b/superset/db_engine_specs/databricks.py
@@ -145,7 +145,7 @@ class DatabricksODBCEngineSpec(BaseEngineSpec):
         return HiveEngineSpec.epoch_to_dttm()
 
 
-class DatabricksNativeEngineSpec(DatabricksODBCEngineSpec, BasicParametersMixin):
+class DatabricksNativeEngineSpec(BasicParametersMixin, DatabricksODBCEngineSpec):
     engine_name = "Databricks"
 
     engine = "databricks"
diff --git a/superset/db_engine_specs/mysql.py b/superset/db_engine_specs/mysql.py
index 687ffee7d5..fc0606697b 100644
--- a/superset/db_engine_specs/mysql.py
+++ b/superset/db_engine_specs/mysql.py
@@ -62,7 +62,7 @@ SYNTAX_ERROR_REGEX = re.compile(
 )
 
 
-class MySQLEngineSpec(BaseEngineSpec, BasicParametersMixin):
+class MySQLEngineSpec(BasicParametersMixin, BaseEngineSpec):
     engine = "mysql"
     engine_name = "MySQL"
     max_column_name_length = 64
diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py
index 7512aac606..7f542365dc 100644
--- a/superset/db_engine_specs/postgres.py
+++ b/superset/db_engine_specs/postgres.py
@@ -183,7 +183,7 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
         return "(timestamp 'epoch' + {col} * interval '1 second')"
 
 
-class PostgresEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
+class PostgresEngineSpec(BasicParametersMixin, PostgresBaseEngineSpec):
     engine = "postgresql"
     engine_aliases = {"postgres"}
     supports_dynamic_schema = True
diff --git a/superset/db_engine_specs/redshift.py b/superset/db_engine_specs/redshift.py
index 2e746a6349..925e0424e4 100644
--- a/superset/db_engine_specs/redshift.py
+++ b/superset/db_engine_specs/redshift.py
@@ -55,7 +55,7 @@ CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
 )
 
 
-class RedshiftEngineSpec(PostgresBaseEngineSpec, BasicParametersMixin):
+class RedshiftEngineSpec(BasicParametersMixin, PostgresBaseEngineSpec):
     engine = "redshift"
     engine_name = "Amazon Redshift"
     max_column_name_length = 127
diff --git a/superset/key_value/models.py b/superset/key_value/models.py
index f92457d190..7a3f5e52a2 100644
--- a/superset/key_value/models.py
+++ b/superset/key_value/models.py
@@ -24,7 +24,7 @@ from superset.models.helpers import AuditMixinNullable, ImportExportMixin
 VALUE_MAX_SIZE = 2**24 - 1
 
 
-class KeyValueEntry(Model, AuditMixinNullable, ImportExportMixin):
+class KeyValueEntry(AuditMixinNullable, ImportExportMixin, Model):
     """Key value store entity"""
 
     __tablename__ = "key_value"
diff --git a/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py b/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py
index 60c5a6687e..1bf5e2ecaf 100644
--- a/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py
+++ b/superset/migrations/versions/2016-06-27_08-43_27ae655e4247_make_creator_owners.py
@@ -79,7 +79,7 @@ class AuditMixin:
         )
 
 
-class Slice(Base, AuditMixin):
+class Slice(AuditMixin, Base):
     """Declarative class to do query in upgrade"""
 
     __tablename__ = "slices"
@@ -87,7 +87,7 @@ class Slice(Base, AuditMixin):
     owners = relationship("User", secondary=slice_user)
 
 
-class Dashboard(Base, AuditMixin):
+class Dashboard(AuditMixin, Base):
     """Declarative class to do query in upgrade"""
 
     __tablename__ = "dashboards"
diff --git a/superset/migrations/versions/2018-07-26_11-10_c82ee8a39623_add_implicit_tags.py b/superset/migrations/versions/2018-07-26_11-10_c82ee8a39623_add_implicit_tags.py
index c6a66d6b53..75151d3403 100644
--- a/superset/migrations/versions/2018-07-26_11-10_c82ee8a39623_add_implicit_tags.py
+++ b/superset/migrations/versions/2018-07-26_11-10_c82ee8a39623_add_implicit_tags.py
@@ -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)
diff --git a/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py b/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py
index 574ca1536a..980ca56f62 100644
--- a/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py
+++ b/superset/migrations/versions/2020-09-28_17-57_b56500de1855_add_uuid_column_to_import_mixin.py
@@ -68,7 +68,7 @@ table_names = [
     "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
 }
 
diff --git a/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py b/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py
index ffe0caf64c..bda21e4752 100644
--- a/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py
+++ b/superset/migrations/versions/2020-10-21_21-09_96e99fb176a0_add_import_mixing_to_saved_query.py
@@ -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"
 
 
diff --git a/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py b/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py
index b51f6c78ac..a1e0f855fc 100644
--- a/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py
+++ b/superset/migrations/versions/2022-04-01_14-38_a9422eeaae74_new_dataset_models_take_2.py
@@ -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)
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index 919c832ab5..b965c8f6a0 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -147,7 +147,7 @@ DashboardRoles = Table(
 
 
 # pylint: disable=too-many-public-methods
-class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
+class Dashboard(AuditMixinNullable, ImportExportMixin, Model):
     """The dashboard object!"""
 
     __tablename__ = "dashboards"
diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index 7e63e984df..ca530ff8b9 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -66,7 +66,7 @@ logger = logging.getLogger(__name__)
 
 
 class Query(
-    Model, ExtraJSONMixin, ExploreMixin
+    ExtraJSONMixin, ExploreMixin, Model
 ):  # pylint: disable=abstract-method,too-many-public-methods
     """ORM model for SQL query
 
@@ -355,7 +355,7 @@ class Query(
         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"
@@ -442,7 +442,7 @@ class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
         return self._last_run_delta_humanized
 
 
-class TabState(Model, AuditMixinNullable, ExtraJSONMixin):
+class TabState(AuditMixinNullable, ExtraJSONMixin, Model):
     __tablename__ = "tab_state"
 
     # basic info
@@ -505,7 +505,7 @@ class TabState(Model, AuditMixinNullable, ExtraJSONMixin):
         }
 
 
-class TableSchema(Model, AuditMixinNullable, ExtraJSONMixin):
+class TableSchema(AuditMixinNullable, ExtraJSONMixin, Model):
     __tablename__ = "table_schema"
 
     id = Column(Integer, primary_key=True, autoincrement=True)
diff --git a/superset/reports/models.py b/superset/reports/models.py
index 5c47f41456..1eb38af8b5 100644
--- a/superset/reports/models.py
+++ b/superset/reports/models.py
@@ -106,7 +106,7 @@ report_schedule_user = Table(
 )
 
 
-class ReportSchedule(Model, AuditMixinNullable, ExtraJSONMixin):
+class ReportSchedule(AuditMixinNullable, ExtraJSONMixin, Model):
 
     """
     Report Schedules, supports alerts and reports
diff --git a/superset/tables/models.py b/superset/tables/models.py
index dccb4f7f04..11f1021197 100644
--- a/superset/tables/models.py
+++ b/superset/tables/models.py
@@ -64,7 +64,7 @@ table_column_association_table = sa.Table(
 )
 
 
-class Table(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
+class Table(AuditMixinNullable, ExtraJSONMixin, ImportExportMixin, Model):
     """
     A table/view in a database.
     """
diff --git a/tests/integration_tests/charts/api_tests.py b/tests/integration_tests/charts/api_tests.py
index 69888104fa..a58ce1779e 100644
--- a/tests/integration_tests/charts/api_tests.py
+++ b/tests/integration_tests/charts/api_tests.py
@@ -73,7 +73,7 @@ CHART_DATA_URI = "api/v1/chart/data"
 CHARTS_FIXTURE_COUNT = 10
 
 
-class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
+class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
     resource_name = "chart"
 
     @pytest.fixture(autouse=True)
diff --git a/tests/integration_tests/dashboards/api_tests.py b/tests/integration_tests/dashboards/api_tests.py
index a5c44f9f08..6b435da997 100644
--- a/tests/integration_tests/dashboards/api_tests.py
+++ b/tests/integration_tests/dashboards/api_tests.py
@@ -63,7 +63,7 @@ from tests.integration_tests.fixtures.world_bank_dashboard import (
 DASHBOARDS_FIXTURE_COUNT = 10
 
 
-class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
+class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase):
     resource_name = "dashboard"
 
     dashboards: list[Dashboard] = []
diff --git a/tests/integration_tests/profile_tests.py b/tests/integration_tests/profile_tests.py
index aa5448139e..5a0efc7509 100644
--- a/tests/integration_tests/profile_tests.py
+++ b/tests/integration_tests/profile_tests.py
@@ -31,7 +31,7 @@ from tests.integration_tests.insert_chart_mixin import InsertChartMixin
 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(
diff --git a/tests/unit_tests/databases/schema_tests.py b/tests/unit_tests/databases/schema_tests.py
index c9fca22d1b..b86f1b4afe 100644
--- a/tests/unit_tests/databases/schema_tests.py
+++ b/tests/unit_tests/databases/schema_tests.py
@@ -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()