Skip to content

Commit

Permalink
adding useful comments and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fisjac committed Oct 24, 2024
1 parent bdffa63 commit 91b762d
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91b762d

Please sign in to comment.