diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa0cf4af62d1a..fe7ca007e91ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,10 +20,23 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.941 + rev: v1.3.0 hooks: - id: mypy - additional_dependencies: [types-all] + args: [--check-untyped-defs] + additional_dependencies: + [ + types-simplejson, + types-python-dateutil, + types-requests, + types-redis, + types-pytz, + types-croniter, + types-PyYAML, + types-setuptools, + types-paramiko, + types-Markdown, + ] - repo: https://github.com/peterdemin/pip-compile-multi rev: v2.4.1 hooks: diff --git a/superset/charts/api.py b/superset/charts/api.py index 88d74f875e5b3..3f397d1bd75ab 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -780,7 +780,7 @@ def export(self, **kwargs: Any) -> Response: buf, mimetype="application/zip", as_attachment=True, - attachment_filename=filename, + download_name=filename, ) if token: response.set_cookie(token, "done", max_age=600) diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py index 6f478e22ccc65..f5a0434c538eb 100644 --- a/superset/dashboards/api.py +++ b/superset/dashboards/api.py @@ -803,7 +803,7 @@ def export(self, **kwargs: Any) -> Response: buf, mimetype="application/zip", as_attachment=True, - attachment_filename=filename, + download_name=filename, ) if token: response.set_cookie(token, "done", max_age=600) diff --git a/superset/databases/api.py b/superset/databases/api.py index c28519874747f..3d4e94153f2f6 100644 --- a/superset/databases/api.py +++ b/superset/databases/api.py @@ -1054,7 +1054,7 @@ def export(self, **kwargs: Any) -> Response: buf, mimetype="application/zip", as_attachment=True, - attachment_filename=filename, + download_name=filename, ) if token: response.set_cookie(token, "done", max_age=600) @@ -1263,12 +1263,10 @@ def available(self) -> Response: and hasattr(engine_spec, "sqlalchemy_uri_placeholder") and getattr(engine_spec, "default_driver") in drivers ): - payload[ - "parameters" - ] = engine_spec.parameters_json_schema() # type: ignore + payload["parameters"] = engine_spec.parameters_json_schema() payload[ "sqlalchemy_uri_placeholder" - ] = engine_spec.sqlalchemy_uri_placeholder # type: ignore + ] = engine_spec.sqlalchemy_uri_placeholder available_databases.append(payload) diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index e318e41121435..f06ff0189ab0e 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -298,7 +298,7 @@ def build_sqlalchemy_uri( ) # validate parameters - parameters = engine_spec.parameters_schema.load(parameters) # type: ignore + parameters = engine_spec.parameters_schema.load(parameters) serialized_encrypted_extra = data.get("masked_encrypted_extra") or "{}" try: @@ -306,7 +306,7 @@ def build_sqlalchemy_uri( except json.decoder.JSONDecodeError: encrypted_extra = {} - data["sqlalchemy_uri"] = engine_spec.build_sqlalchemy_uri( # type: ignore + data["sqlalchemy_uri"] = engine_spec.build_sqlalchemy_uri( parameters, encrypted_extra, ) @@ -482,7 +482,6 @@ class Meta: # pylint: disable=too-few-public-methods class DatabaseTestConnectionSchema(Schema, DatabaseParametersSchemaMixin): - rename_encrypted_extra = pre_load(rename_encrypted_extra) database_name = fields.String( diff --git a/superset/datasets/api.py b/superset/datasets/api.py index 16975675e6744..247e6b5ffdf31 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -514,7 +514,7 @@ def export(self, **kwargs: Any) -> Response: buf, mimetype="application/zip", as_attachment=True, - attachment_filename=filename, + download_name=filename, ) if token: response.set_cookie(token, "done", max_age=600) diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py index 87f362acc8f84..33c848cfd51fb 100644 --- a/superset/db_engine_specs/presto.py +++ b/superset/db_engine_specs/presto.py @@ -1272,10 +1272,10 @@ def handle_cursor(cls, cursor: "Cursor", query: Query, session: Session) -> None def _extract_error_message(cls, ex: Exception) -> str: if ( hasattr(ex, "orig") - and type(ex.orig).__name__ == "DatabaseError" # type: ignore - and isinstance(ex.orig[0], dict) # type: ignore + and type(ex.orig).__name__ == "DatabaseError" + and isinstance(ex.orig[0], dict) ): - error_dict = ex.orig[0] # type: ignore + error_dict = ex.orig[0] return "{} at {}: {}".format( error_dict.get("errorName"), error_dict.get("errorLocation"), diff --git a/superset/embedded/view.py b/superset/embedded/view.py index 8dd383aadafec..b7062c0b5ee64 100644 --- a/superset/embedded/view.py +++ b/superset/embedded/view.py @@ -55,6 +55,8 @@ def embedded( if not embedded: abort(404) + assert embedded is not None + # validate request referrer in allowed domains is_referrer_allowed = not embedded.allowed_domains for domain in embedded.allowed_domains: diff --git a/superset/exceptions.py b/superset/exceptions.py index cee15be376394..32b06203cdb1e 100644 --- a/superset/exceptions.py +++ b/superset/exceptions.py @@ -54,7 +54,7 @@ def to_dict(self) -> Dict[str, Any]: if self.error_type: rv["error_type"] = self.error_type if self.exception is not None and hasattr(self.exception, "to_dict"): - rv = {**rv, **self.exception.to_dict()} # type: ignore + rv = {**rv, **self.exception.to_dict()} return rv diff --git a/superset/extensions/__init__.py b/superset/extensions/__init__.py index e2e5592e1edb9..f63338597284a 100644 --- a/superset/extensions/__init__.py +++ b/superset/extensions/__init__.py @@ -107,7 +107,7 @@ def __init__(self, interval: float = 1e-4) -> None: self.interval = interval def init_app(self, app: Flask) -> None: - app.wsgi_app = SupersetProfiler(app.wsgi_app, self.interval) # type: ignore + app.wsgi_app = SupersetProfiler(app.wsgi_app, self.interval) APP_DIR = os.path.join(os.path.dirname(__file__), os.path.pardir) diff --git a/superset/importexport/api.py b/superset/importexport/api.py index 26bc78e5d7a84..3a159c140e593 100644 --- a/superset/importexport/api.py +++ b/superset/importexport/api.py @@ -87,7 +87,7 @@ def export(self) -> Response: buf, mimetype="application/zip", as_attachment=True, - attachment_filename=filename, + download_name=filename, ) return response diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index ef332e502da2c..f06dbdb907aeb 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -564,7 +564,7 @@ def configure_middlewares(self) -> None: CORS(self.superset_app, **self.config["CORS_OPTIONS"]) if self.config["ENABLE_PROXY_FIX"]: - self.superset_app.wsgi_app = ProxyFix( # type: ignore + self.superset_app.wsgi_app = ProxyFix( self.superset_app.wsgi_app, **self.config["PROXY_FIX_CONFIG"] ) @@ -583,9 +583,7 @@ def __call__( environ["wsgi.input_terminated"] = True return self.app(environ, start_response) - self.superset_app.wsgi_app = ChunkedEncodingFix( # type: ignore - self.superset_app.wsgi_app # type: ignore - ) + self.superset_app.wsgi_app = ChunkedEncodingFix(self.superset_app.wsgi_app) if self.config["UPLOAD_FOLDER"]: try: @@ -594,9 +592,7 @@ def __call__( pass for middleware in self.config["ADDITIONAL_MIDDLEWARE"]: - self.superset_app.wsgi_app = middleware( # type: ignore - self.superset_app.wsgi_app - ) + self.superset_app.wsgi_app = middleware(self.superset_app.wsgi_app) # Flask-Compress Compress(self.superset_app) diff --git a/superset/jinja_context.py b/superset/jinja_context.py index ffbab4f9bcd7d..4fcb6c374d9c8 100644 --- a/superset/jinja_context.py +++ b/superset/jinja_context.py @@ -190,7 +190,7 @@ def url_param( # pylint: disable=import-outside-toplevel from superset.views.utils import get_form_data - if has_request_context() and request.args.get(param): # type: ignore + if has_request_context() and request.args.get(param): return request.args.get(param, default) form_data, _ = get_form_data() diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py index e2192ae2f2ccd..3715eb7bc6de3 100644 --- a/superset/models/dashboard.py +++ b/superset/models/dashboard.py @@ -319,8 +319,8 @@ def datasets_trimmed_for_slices(self) -> List[Dict[str, Any]]: return result - @property # type: ignore - def params(self) -> str: # type: ignore + @property + def params(self) -> str: return self.json_metadata @params.setter diff --git a/superset/queries/saved_queries/api.py b/superset/queries/saved_queries/api.py index 2b70b582bb5f4..5d1fb2d2b2655 100644 --- a/superset/queries/saved_queries/api.py +++ b/superset/queries/saved_queries/api.py @@ -275,7 +275,7 @@ def export(self, **kwargs: Any) -> Response: buf, mimetype="application/zip", as_attachment=True, - attachment_filename=filename, + download_name=filename, ) if token: response.set_cookie(token, "done", max_age=600) diff --git a/superset/result_set.py b/superset/result_set.py index 1c4ae98dc9112..170de1869c830 100644 --- a/superset/result_set.py +++ b/superset/result_set.py @@ -70,14 +70,14 @@ def stringify_values(array: NDArray[Any]) -> NDArray[Any]: for obj in it: if na_obj := pd.isna(obj): # pandas type cannot be converted to string - obj[na_obj] = None # type: ignore + obj[na_obj] = None else: try: # for simple string conversions # this handles odd character types better - obj[...] = obj.astype(str) # type: ignore + obj[...] = obj.astype(str) except ValueError: - obj[...] = stringify(obj) # type: ignore + obj[...] = stringify(obj) return result diff --git a/superset/sqllab/api.py b/superset/sqllab/api.py index 5915601c0de15..0f7a5236c5b66 100644 --- a/superset/sqllab/api.py +++ b/superset/sqllab/api.py @@ -280,7 +280,7 @@ def _create_sql_json_command( ) execution_context_convertor = ExecutionContextConvertor() execution_context_convertor.set_max_row_in_display( - int(config.get("DISPLAY_MAX_ROW")) # type: ignore + int(config.get("DISPLAY_MAX_ROW")) ) return ExecuteSqlCommand( execution_context, @@ -305,7 +305,7 @@ def _create_sql_json_executor( sql_json_executor = SynchronousSqlJsonExecutor( query_dao, get_sql_results, - config.get("SQLLAB_TIMEOUT"), # type: ignore + config.get("SQLLAB_TIMEOUT"), is_feature_enabled("SQLLAB_BACKEND_PERSISTENCE"), ) return sql_json_executor diff --git a/superset/sqllab/exceptions.py b/superset/sqllab/exceptions.py index c0096d5db6b47..8a4db2195015a 100644 --- a/superset/sqllab/exceptions.py +++ b/superset/sqllab/exceptions.py @@ -33,7 +33,7 @@ class SqlLabException(SupersetException): failed_reason_msg: str suggestion_help_msg: Optional[str] - def __init__( # pylint: disable=too-many-arguments + def __init__( self, sql_json_execution_context: SqlJsonExecutionContext, error_type: Optional[SupersetErrorType] = None, @@ -48,13 +48,13 @@ def __init__( # pylint: disable=too-many-arguments if exception is not None: if ( hasattr(exception, "error_type") - and exception.error_type is not None # type: ignore + and exception.error_type is not None ): - error_type = exception.error_type # type: ignore + error_type = exception.error_type elif hasattr(exception, "error") and isinstance( - exception.error, SupersetError # type: ignore + exception.error, SupersetError ): - error_type = exception.error.error_type # type: ignore + error_type = exception.error.error_type else: error_type = SupersetErrorType.GENERIC_BACKEND_ERROR @@ -79,9 +79,9 @@ def _get_reason( return ": {}".format(reason_message) if exception is not None: if hasattr(exception, "get_message"): - return ": {}".format(exception.get_message()) # type: ignore + return ": {}".format(exception.get_message()) if hasattr(exception, "message"): - return ": {}".format(exception.message) # type: ignore + return ": {}".format(exception.message) return ": {}".format(str(exception)) return "" diff --git a/superset/sqllab/query_render.py b/superset/sqllab/query_render.py index 2854a7e390774..1369e78db15de 100644 --- a/superset/sqllab/query_render.py +++ b/superset/sqllab/query_render.py @@ -48,8 +48,7 @@ class SqlQueryRenderImpl(SqlQueryRender): def __init__( self, sql_template_factory: Callable[..., BaseTemplateProcessor] ) -> None: - - self._sql_template_processor_factory = sql_template_factory # type: ignore + self._sql_template_processor_factory = sql_template_factory def render(self, execution_context: SqlJsonExecutionContext) -> str: query_model = execution_context.query @@ -76,9 +75,7 @@ def _validate( if is_feature_enabled("ENABLE_TEMPLATE_PROCESSING"): # pylint: disable=protected-access syntax_tree = sql_template_processor._env.parse(rendered_query) - undefined_parameters = find_undeclared_variables( # type: ignore - syntax_tree - ) + undefined_parameters = find_undeclared_variables(syntax_tree) if undefined_parameters: self._raise_undefined_parameter_exception( execution_context, undefined_parameters diff --git a/superset/sqllab/sql_json_executer.py b/superset/sqllab/sql_json_executer.py index 3d55047b41042..e4e6b60654b87 100644 --- a/superset/sqllab/sql_json_executer.py +++ b/superset/sqllab/sql_json_executer.py @@ -64,7 +64,7 @@ class SqlJsonExecutorBase(SqlJsonExecutor, ABC): def __init__(self, query_dao: QueryDAO, get_sql_results_task: GetSqlResultsTask): self._query_dao = query_dao - self._get_sql_results_task = get_sql_results_task # type: ignore + self._get_sql_results_task = get_sql_results_task class SynchronousSqlJsonExecutor(SqlJsonExecutorBase): @@ -163,7 +163,6 @@ def execute( rendered_query: str, log_params: Optional[Dict[str, Any]], ) -> SqlJsonExecutionStatus: - query_id = execution_context.query.id logger.info("Query %i: Running query on a Celery worker", query_id) try: diff --git a/superset/tasks/async_queries.py b/superset/tasks/async_queries.py index 1157c5fd37e1f..8d2b488480c5a 100644 --- a/superset/tasks/async_queries.py +++ b/superset/tasks/async_queries.py @@ -90,7 +90,9 @@ def load_chart_data_into_cache( raise ex except Exception as ex: # TODO: QueryContext should support SIP-40 style errors - error = ex.message if hasattr(ex, "message") else str(ex) # type: ignore # pylint: disable=no-member + error = ( + ex.message if hasattr(ex, "message") else str(ex) + ) # pylint: disable=no-member errors = [{"message": error}] async_query_manager.update_job( job_metadata, async_query_manager.STATUS_ERROR, errors=errors @@ -157,7 +159,9 @@ def load_explore_json_into_cache( # pylint: disable=too-many-locals if isinstance(ex, SupersetVizException): errors = ex.errors # pylint: disable=no-member else: - error = ex.message if hasattr(ex, "message") else str(ex) # type: ignore # pylint: disable=no-member + error = ( + ex.message if hasattr(ex, "message") else str(ex) + ) # pylint: disable=no-member errors = [error] async_query_manager.update_job( diff --git a/superset/utils/core.py b/superset/utils/core.py index 517ca6e21b008..109d6742b1522 100644 --- a/superset/utils/core.py +++ b/superset/utils/core.py @@ -56,6 +56,7 @@ Iterable, Iterator, List, + Literal, NamedTuple, Optional, Sequence, @@ -655,10 +656,10 @@ def error_msg_from_exception(ex: Exception) -> str: """ msg = "" if hasattr(ex, "message"): - if isinstance(ex.message, dict): # type: ignore + if isinstance(ex.message, dict): msg = ex.message.get("message") # type: ignore - elif ex.message: # type: ignore - msg = ex.message # type: ignore + elif ex.message: + msg = ex.message return msg or str(ex) @@ -1148,9 +1149,7 @@ def merge_extra_form_data(form_data: Dict[str, Any]) -> None: append_adhoc_filters: List[AdhocFilterClause] = extra_form_data.get( "adhoc_filters", [] ) - adhoc_filters.extend( - {"isExtra": True, **fltr} for fltr in append_adhoc_filters # type: ignore - ) + adhoc_filters.extend({"isExtra": True, **fltr} for fltr in append_adhoc_filters) # type: ignore if append_filters: for key, value in form_data.items(): if re.match("adhoc_filter.*", key): @@ -1667,7 +1666,7 @@ def get_form_data_token(form_data: Dict[str, Any]) -> str: return form_data.get("token") or "token_" + uuid.uuid4().hex[:8] -def get_column_name_from_column(column: Column) -> Optional[str]: +def get_column_name_from_column(column: Column) -> Optional[Column]: """ Extract the physical column that a column is referencing. If the column is an adhoc column, always returns `None`. @@ -1677,10 +1676,12 @@ def get_column_name_from_column(column: Column) -> Optional[str]: """ if is_adhoc_column(column): return None - return column # type: ignore + return column -def get_column_names_from_columns(columns: List[Column]) -> List[str]: +def get_column_names_from_columns( + columns: List[Column], +) -> List[Union[AdhocColumn, str]]: """ Extract the physical columns that a list of columns are referencing. Ignore adhoc columns @@ -1785,7 +1786,7 @@ def indexed( return idx -def is_test() -> bool: +def is_test() -> Literal[0, 1]: return strtobool(os.environ.get("SUPERSET_TESTENV", "false")) @@ -1793,7 +1794,6 @@ def get_time_filter_status( datasource: "BaseDatasource", applied_time_extras: Dict[str, str], ) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]: - temporal_columns: Set[Any] if datasource.type == "query": temporal_columns = { diff --git a/superset/utils/decorators.py b/superset/utils/decorators.py index f80a578674abf..e77a5599057a1 100644 --- a/superset/utils/decorators.py +++ b/superset/utils/decorators.py @@ -47,7 +47,7 @@ def wrapped(*args: Any, **kwargs: Any) -> Any: except Exception as ex: if ( hasattr(ex, "status") - and ex.status < 500 # type: ignore # pylint: disable=no-member + and ex.status < 500 # pylint: disable=no-member ): current_app.config["STATS_LOGGER"].gauge( f"{metric_prefix_}.warning", 1 diff --git a/superset/utils/encrypt.py b/superset/utils/encrypt.py index 0c230c6cd9248..52b784bb23f88 100644 --- a/superset/utils/encrypt.py +++ b/superset/utils/encrypt.py @@ -60,7 +60,7 @@ def __init__(self) -> None: def init_app(self, app: Flask) -> None: self._config = app.config - self._concrete_type_adapter = self._config[ + self._concrete_type_adapter = self._config[ # type: ignore "SQLALCHEMY_ENCRYPTED_FIELD_TYPE_ADAPTER" ]() diff --git a/superset/utils/machine_auth.py b/superset/utils/machine_auth.py index d58f739f7713c..b770245137851 100644 --- a/superset/utils/machine_auth.py +++ b/superset/utils/machine_auth.py @@ -52,7 +52,7 @@ def authenticate_webdriver( :return: The WebDriver passed in (fluent) """ # Short-circuit this method if we have an override configured - if self._auth_webdriver_func_override: + if self._auth_webdriver_func_override is not None: return self._auth_webdriver_func_override(driver, user) # Setting cookies requires doing a request first diff --git a/superset/utils/pandas_postprocessing/boxplot.py b/superset/utils/pandas_postprocessing/boxplot.py index d4c78bf15e8c8..399cf569fb25c 100644 --- a/superset/utils/pandas_postprocessing/boxplot.py +++ b/superset/utils/pandas_postprocessing/boxplot.py @@ -99,8 +99,8 @@ def whisker_low(series: Series) -> float: return np.nanpercentile(series, low) else: - whisker_high = np.max # type: ignore - whisker_low = np.min # type: ignore + whisker_high = np.max + whisker_low = np.min def outliers(series: Series) -> Set[float]: above = series[series > whisker_high(series)] diff --git a/superset/utils/pandas_postprocessing/flatten.py b/superset/utils/pandas_postprocessing/flatten.py index 1026164e454ee..db783c4bed264 100644 --- a/superset/utils/pandas_postprocessing/flatten.py +++ b/superset/utils/pandas_postprocessing/flatten.py @@ -85,7 +85,7 @@ def flatten( _columns = [] for series in df.columns.to_flat_index(): _cells = [] - for cell in series if is_sequence(series) else [series]: # type: ignore + for cell in series if is_sequence(series) else [series]: if pd.notnull(cell): # every cell should be converted to string and escape comma _cells.append(escape_separator(str(cell))) diff --git a/superset/utils/url_map_converters.py b/superset/utils/url_map_converters.py index c5eaf3b359f06..fbd9c800b0a88 100644 --- a/superset/utils/url_map_converters.py +++ b/superset/utils/url_map_converters.py @@ -23,7 +23,7 @@ class RegexConverter(BaseConverter): def __init__(self, url_map: Map, *items: List[str]) -> None: - super().__init__(url_map) # type: ignore + super().__init__(url_map) self.regex = items[0] diff --git a/superset/views/base.py b/superset/views/base.py index ec74b8ccdb3a0..f4a945484cede 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -486,7 +486,7 @@ def show_http_exception(ex: HTTPException) -> FlaskResponse: and ex.code in {404, 500} ): path = resource_filename("superset", f"static/assets/{ex.code}.html") - return send_file(path, cache_timeout=0), ex.code + return send_file(path, max_age=0), ex.code return json_errors_response( errors=[ @@ -508,7 +508,7 @@ def show_command_errors(ex: CommandException) -> FlaskResponse: logger.warning("CommandException", exc_info=True) if "text/html" in request.accept_mimetypes and not config["DEBUG"]: path = resource_filename("superset", "static/assets/500.html") - return send_file(path, cache_timeout=0), 500 + return send_file(path, max_age=0), 500 extra = ex.normalized_messages() if isinstance(ex, CommandInvalidError) else {} return json_errors_response( @@ -530,7 +530,7 @@ def show_unexpected_exception(ex: Exception) -> FlaskResponse: logger.exception(ex) if "text/html" in request.accept_mimetypes and not config["DEBUG"]: path = resource_filename("superset", "static/assets/500.html") - return send_file(path, cache_timeout=0), 500 + return send_file(path, max_age=0), 500 return json_errors_response( errors=[ @@ -729,7 +729,7 @@ def apply_http_headers(response: Response) -> Response: """Applies the configuration's http headers to all responses""" # HTTP_HEADERS is deprecated, this provides backwards compatibility - response.headers.extend( # type: ignore + response.headers.extend( {**config["OVERRIDE_HTTP_HEADERS"], **config["HTTP_HEADERS"]} ) diff --git a/superset/views/base_api.py b/superset/views/base_api.py index 57d7e17367922..b6f1644bdeb24 100644 --- a/superset/views/base_api.py +++ b/superset/views/base_api.py @@ -112,10 +112,7 @@ def wraps(self: BaseSupersetApiMixin, *args: Any, **kwargs: Any) -> Response: try: duration, response = time_function(f, self, *args, **kwargs) except Exception as ex: - if ( - hasattr(ex, "status") - and ex.status < 500 # type: ignore # pylint: disable=no-member - ): + if hasattr(ex, "status") and ex.status < 500: # pylint: disable=no-member self.incr_stats("warning", func_name) else: self.incr_stats("error", func_name) diff --git a/superset/views/core.py b/superset/views/core.py index b1580756b71a2..7f6364bb8a139 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1844,6 +1844,8 @@ def dashboard( if not dashboard: abort(404) + assert dashboard is not None + has_access_ = False for datasource in dashboard.datasources: datasource = DatasourceDAO.get_datasource( @@ -2367,7 +2369,7 @@ def _create_sql_json_command( ) execution_context_convertor = ExecutionContextConvertor() execution_context_convertor.set_max_row_in_display( - int(config.get("DISPLAY_MAX_ROW")) # type: ignore + int(config.get("DISPLAY_MAX_ROW")) ) return ExecuteSqlCommand( execution_context, @@ -2392,7 +2394,7 @@ def _create_sql_json_executor( sql_json_executor = SynchronousSqlJsonExecutor( query_dao, get_sql_results, - config.get("SQLLAB_TIMEOUT"), # type: ignore + config.get("SQLLAB_TIMEOUT"), is_feature_enabled("SQLLAB_BACKEND_PERSISTENCE"), ) return sql_json_executor diff --git a/superset/views/utils.py b/superset/views/utils.py index cd84d8e0a58dd..35a39fdc9c04d 100644 --- a/superset/views/utils.py +++ b/superset/views/utils.py @@ -153,7 +153,7 @@ def get_form_data( # pylint: disable=too-many-locals ) -> Tuple[Dict[str, Any], Optional[Slice]]: form_data: Dict[str, Any] = initial_form_data or {} - if has_request_context(): # type: ignore + if has_request_context(): # chart data API requests are JSON request_json_data = ( request.json["queries"][0] @@ -186,7 +186,7 @@ def get_form_data( # pylint: disable=too-many-locals json_data = form_data["queries"][0] if "queries" in form_data else {} form_data.update(json_data) - if has_request_context(): # type: ignore + if has_request_context(): url_id = request.args.get("r") if url_id: saved_url = db.session.query(models.Url).filter_by(id=url_id).first() diff --git a/tests/integration_tests/reports/scheduler_tests.py b/tests/integration_tests/reports/scheduler_tests.py index 3dd6e72941e2e..d121e87d45dfe 100644 --- a/tests/integration_tests/reports/scheduler_tests.py +++ b/tests/integration_tests/reports/scheduler_tests.py @@ -22,7 +22,7 @@ import pytest from flask_appbuilder.security.sqla.models import User from freezegun import freeze_time -from freezegun.api import FakeDatetime # type: ignore +from freezegun.api import FakeDatetime from superset.extensions import db from superset.reports.models import ReportScheduleType diff --git a/tests/unit_tests/tasks/test_cron_util.py b/tests/unit_tests/tasks/test_cron_util.py index d0f9ae21705e2..282dc99860f33 100644 --- a/tests/unit_tests/tasks/test_cron_util.py +++ b/tests/unit_tests/tasks/test_cron_util.py @@ -21,7 +21,7 @@ import pytz from dateutil import parser from freezegun import freeze_time -from freezegun.api import FakeDatetime # type: ignore +from freezegun.api import FakeDatetime from superset.tasks.cron_util import cron_schedule_window