diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8731b8aa3d1bb..1f29891dfddc9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910 + rev: v0.941 hooks: - id: mypy additional_dependencies: [types-all] diff --git a/RELEASING/changelog.py b/RELEASING/changelog.py index 0cf600280b799..441e3092d047e 100644 --- a/RELEASING/changelog.py +++ b/RELEASING/changelog.py @@ -381,12 +381,12 @@ def change_log( with open(csv, "w") as csv_file: log_items = list(logs) field_names = log_items[0].keys() - writer = lib_csv.DictWriter( # type: ignore + writer = lib_csv.DictWriter( csv_file, delimiter=",", quotechar='"', quoting=lib_csv.QUOTE_ALL, - fieldnames=field_names, # type: ignore + fieldnames=field_names, ) writer.writeheader() for log in logs: diff --git a/superset/charts/data/api.py b/superset/charts/data/api.py index dc92d97458c41..73468d651cbc5 100644 --- a/superset/charts/data/api.py +++ b/superset/charts/data/api.py @@ -306,16 +306,13 @@ def _run_async( Execute command as an async query. """ # First, look for the chart query results in the cache. + result = None try: result = command.run(force_cached=True) + if result is not None: + return self._send_chart_response(result) except ChartDataCacheLoadError: - result = None # type: ignore - - already_cached_result = result is not None - - # If the chart query has already been cached, return it immediately. - if already_cached_result: - return self._send_chart_response(result) + pass # Otherwise, kick off a background job to run the chart query. # Clients will either poll or be notified of query completion, diff --git a/superset/cli/main.py b/superset/cli/main.py index 45b4c9e46a101..a1a03e9de26d0 100755 --- a/superset/cli/main.py +++ b/superset/cli/main.py @@ -45,7 +45,7 @@ def make_shell_context() -> Dict[str, Any]: # add sub-commands for load, module_name, is_pkg in pkgutil.walk_packages( - cli.__path__, cli.__name__ + "." # type: ignore + cli.__path__, cli.__name__ + "." ): module = importlib.import_module(module_name) for attribute in module.__dict__.values(): diff --git a/superset/models/helpers.py b/superset/models/helpers.py index f1adadfbc453f..86ac2c1a98717 100644 --- a/superset/models/helpers.py +++ b/superset/models/helpers.py @@ -221,7 +221,7 @@ def import_from_dict( if not obj: is_new_obj = True # Create new DB object - obj = cls(**dict_rep) # type: ignore + obj = cls(**dict_rep) logger.info("Importing new %s %s", obj.__tablename__, str(obj)) if cls.export_parent and parent: setattr(obj, cls.export_parent, parent) diff --git a/superset/reports/commands/alert.py b/superset/reports/commands/alert.py index e00ac9f2df5c1..f5879a037f378 100644 --- a/superset/reports/commands/alert.py +++ b/superset/reports/commands/alert.py @@ -77,8 +77,7 @@ def run(self) -> bool: threshold = json.loads(self._report_schedule.validator_config_json)[ "threshold" ] - - return OPERATOR_FUNCTIONS[operator](self._result, threshold) + return OPERATOR_FUNCTIONS[operator](self._result, threshold) # type: ignore except (KeyError, json.JSONDecodeError) as ex: raise AlertValidatorConfigError() from ex diff --git a/superset/reports/notifications/base.py b/superset/reports/notifications/base.py index 3331e51297a75..06bfecf790144 100644 --- a/superset/reports/notifications/base.py +++ b/superset/reports/notifications/base.py @@ -50,7 +50,7 @@ class BaseNotification: # pylint: disable=too-few-public-methods """ def __init_subclass__(cls, *args: Any, **kwargs: Any) -> None: - super().__init_subclass__(*args, **kwargs) # type: ignore + super().__init_subclass__(*args, **kwargs) cls.plugins.append(cls) def __init__( diff --git a/superset/utils/async_query_manager.py b/superset/utils/async_query_manager.py index fcda931fcd880..a026fd6f3f3d7 100644 --- a/superset/utils/async_query_manager.py +++ b/superset/utils/async_query_manager.py @@ -71,7 +71,7 @@ class AsyncQueryManager: def __init__(self) -> None: super().__init__() - self._redis: redis.Redis + self._redis: redis.Redis # type: ignore self._stream_prefix: str = "" self._stream_limit: Optional[int] self._stream_limit_firehose: Optional[int] diff --git a/superset/views/core.py b/superset/views/core.py index f014ca2845ea2..6957296ab634c 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -653,14 +653,11 @@ def explore_json( force=force, ) payload = viz_obj.get_payload() + # If the chart query has already been cached, return it immediately. + if payload is not None: + return self.send_data_payload_response(viz_obj, payload) except CacheLoadError: - payload = None # type: ignore - - already_cached_result = payload is not None - - # If the chart query has already been cached, return it immediately. - if already_cached_result: - return self.send_data_payload_response(viz_obj, payload) + pass # Otherwise, kick off a background job to run the chart query. # Clients will either poll or be notified of query completion,