From 91b762dc48a9e6b0df945a343dc45dcc2941e049 Mon Sep 17 00:00:00 2001 From: Jack Fisher Date: Wed, 23 Oct 2024 19:02:07 -0500 Subject: [PATCH] adding useful comments and code cleanup --- superset/models/core.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/superset/models/core.py b/superset/models/core.py index 07382b6cd5964..0027e65b3919c 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -511,23 +511,13 @@ def _get_sqla_engine( # pylint: disable=too-many-locals logger.debug("Database._get_sqla_engine(). Masked URL: %s", str(masked_url)) if self.impersonate_user: - # Checking if the function signature can accept database as a param + # PR #30674 changed the signature of the method to include database. + # This ensures that the change is backwards compatible sig = signature(self.db_engine_spec.update_impersonation_config) + args = [connect_args, str(sqlalchemy_url), effective_username, access_token] if "database" in sig.parameters: - self.db_engine_spec.update_impersonation_config( - self, # expects database as a param - connect_args, - str(sqlalchemy_url), - effective_username, - access_token, - ) - else: - self.db_engine_spec.update_impersonation_config( # type: ignore[call-arg] - connect_args, - str(sqlalchemy_url), # type: ignore[arg-type] - effective_username, # type: ignore[arg-type] - access_token, - ) + args.insert(0, self) + self.db_engine_spec.update_impersonation_config(*args) if connect_args: params["connect_args"] = connect_args