From 3bc6de0866932a8c4f60497de87230a2f3f2168e Mon Sep 17 00:00:00 2001 From: Elizabeth Thompson Date: Wed, 9 Mar 2022 11:48:20 -0800 Subject: [PATCH] lint --- UPDATING.md | 2 +- superset/config.py | 10 +++++++--- superset/db_engine_specs/base.py | 6 ++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/UPDATING.md b/UPDATING.md index ab4a9bb9c359f..19278050ab6d2 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -35,7 +35,7 @@ assists people when migrating to a new version. - [17539](https://github.com/apache/superset/pull/17539): all Superset CLI commands (init, load_examples and etc) require setting the FLASK_APP environment variable (which is set by default when `.flaskenv` is loaded) - [18970](https://github.com/apache/superset/pull/18970): Changes feature flag for the legacy datasource editor (DISABLE_LEGACY_DATASOURCE_EDITOR) in config.py to True, thus disabling the feature from being shown in the client. -- [19083](https://github.com/apache/superset/pull/19083): Updates the mutator function in the config file to take a sql argument and a list of kwargs. Any `SQL_QUERY_MUTATOR` config function overrides will need to be updated to match the new set of params. +- [19083](https://github.com/apache/superset/pull/19083): Updates the mutator function in the config file to take a sql argument and a list of kwargs. Any `SQL_QUERY_MUTATOR` config function overrides will need to be updated to match the new set of params. It is advised regardless of the dictionary args that you list in your function arguments, to keep **kwargs as the last argument to allow for any new kwargs to be passed in. ### Potential Downtime diff --git a/superset/config.py b/superset/config.py index 76f5bea131a8f..f66900d7ea259 100644 --- a/superset/config.py +++ b/superset/config.py @@ -40,7 +40,6 @@ from flask_appbuilder.security.manager import AUTH_DB from pandas._libs.parsers import STR_NA_VALUES # pylint: disable=no-name-in-module from typing_extensions import Literal -from werkzeug.local import LocalProxy from superset.constants import CHANGE_ME_SECRET_KEY from superset.jinja_context import BaseTemplateProcessor @@ -1052,10 +1051,15 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC( # pylint: disable=invalid-name # The use case is can be around adding some sort of comment header # with information such as the username and worker node information # -# def SQL_QUERY_MUTATOR(sql, user_name, security_manager, database): +# def SQL_QUERY_MUTATOR(sql, user_name=user_name, security_manager=security_manager, database=database): # dttm = datetime.now().isoformat() # return f"-- [SQL LAB] {username} {dttm}\n{sql}" -def SQL_QUERY_MUTATOR(sql: str, **kwargs) -> str: +# For backward compatibility, you can unpack any of the above arguments in your +# function definition, but keep the **kwargs as the last argument to allow new args +# to be added later without any errors. +def SQL_QUERY_MUTATOR( # pylint: disable=invalid-name,unused-argument + sql: str, **kwargs: Any +) -> str: return sql diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py index 1bd8423ac3888..e867f200d91a8 100644 --- a/superset/db_engine_specs/base.py +++ b/superset/db_engine_specs/base.py @@ -166,8 +166,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods engine = "base" # str as defined in sqlalchemy.engine.engine engine_aliases: Set[str] = set() - # for user messages, overridden in child classes - engine_name: Optional[str] = None + engine_name: Optional[str] = None # for user messages, overridden in child classes _date_trunc_functions: Dict[str, str] = {} _time_grain_expressions: Dict[Optional[str], str] = {} column_type_mappings: Tuple[ColumnTypeMapping, ...] = ( @@ -1579,8 +1578,7 @@ def build_sqlalchemy_uri( # pylint: disable=unused-argument return str( URL( - # type: ignore - f"{cls.engine}+{cls.default_driver}".rstrip("+"), + f"{cls.engine}+{cls.default_driver}".rstrip("+"), # type: ignore username=parameters.get("username"), password=parameters.get("password"), host=parameters["host"],