mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore(pre-commit): Add pyupgrade and pycln hooks (#24197)
This commit is contained in:
@@ -18,7 +18,7 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Dict, Optional, TYPE_CHECKING, Union
|
||||
from typing import Any, TYPE_CHECKING
|
||||
|
||||
import simplejson
|
||||
from flask import current_app, g, make_response, request, Response
|
||||
@@ -315,7 +315,7 @@ class ChartDataRestApi(ChartRestApi):
|
||||
return self._get_data_response(command, True)
|
||||
|
||||
def _run_async(
|
||||
self, form_data: Dict[str, Any], command: ChartDataCommand
|
||||
self, form_data: dict[str, Any], command: ChartDataCommand
|
||||
) -> Response:
|
||||
"""
|
||||
Execute command as an async query.
|
||||
@@ -344,9 +344,9 @@ class ChartDataRestApi(ChartRestApi):
|
||||
|
||||
def _send_chart_response(
|
||||
self,
|
||||
result: Dict[Any, Any],
|
||||
form_data: Optional[Dict[str, Any]] = None,
|
||||
datasource: Optional[Union[BaseDatasource, Query]] = None,
|
||||
result: dict[Any, Any],
|
||||
form_data: dict[str, Any] | None = None,
|
||||
datasource: BaseDatasource | Query | None = None,
|
||||
) -> Response:
|
||||
result_type = result["query_context"].result_type
|
||||
result_format = result["query_context"].result_format
|
||||
@@ -408,8 +408,8 @@ class ChartDataRestApi(ChartRestApi):
|
||||
self,
|
||||
command: ChartDataCommand,
|
||||
force_cached: bool = False,
|
||||
form_data: Optional[Dict[str, Any]] = None,
|
||||
datasource: Optional[Union[BaseDatasource, Query]] = None,
|
||||
form_data: dict[str, Any] | None = None,
|
||||
datasource: BaseDatasource | Query | None = None,
|
||||
) -> Response:
|
||||
try:
|
||||
result = command.run(force_cached=force_cached)
|
||||
@@ -421,12 +421,12 @@ class ChartDataRestApi(ChartRestApi):
|
||||
return self._send_chart_response(result, form_data, datasource)
|
||||
|
||||
# pylint: disable=invalid-name, no-self-use
|
||||
def _load_query_context_form_from_cache(self, cache_key: str) -> Dict[str, Any]:
|
||||
def _load_query_context_form_from_cache(self, cache_key: str) -> dict[str, Any]:
|
||||
return QueryContextCacheLoader.load(cache_key)
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def _create_query_context_from_form(
|
||||
self, form_data: Dict[str, Any]
|
||||
self, form_data: dict[str, Any]
|
||||
) -> QueryContext:
|
||||
try:
|
||||
return ChartDataQueryContextSchema().load(form_data)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from flask import Request
|
||||
|
||||
@@ -32,7 +32,7 @@ class CreateAsyncChartDataJobCommand:
|
||||
jwt_data = async_query_manager.parse_jwt_from_request(request)
|
||||
self._async_channel_id = jwt_data["channel"]
|
||||
|
||||
def run(self, form_data: Dict[str, Any], user_id: Optional[int]) -> Dict[str, Any]:
|
||||
def run(self, form_data: dict[str, Any], user_id: Optional[int]) -> dict[str, Any]:
|
||||
job_metadata = async_query_manager.init_job(self._async_channel_id, user_id)
|
||||
load_chart_data_into_cache.delay(job_metadata, form_data)
|
||||
return job_metadata
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
from flask_babel import lazy_gettext as _
|
||||
|
||||
@@ -36,7 +36,7 @@ class ChartDataCommand(BaseCommand):
|
||||
def __init__(self, query_context: QueryContext):
|
||||
self._query_context = query_context
|
||||
|
||||
def run(self, **kwargs: Any) -> Dict[str, Any]:
|
||||
def run(self, **kwargs: Any) -> dict[str, Any]:
|
||||
# caching is handled in query_context.get_df_payload
|
||||
# (also evals `force` property)
|
||||
cache_query_context = kwargs.get("cache", False)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
from superset import cache
|
||||
from superset.charts.commands.exceptions import ChartDataCacheLoadError
|
||||
@@ -22,7 +22,7 @@ from superset.charts.commands.exceptions import ChartDataCacheLoadError
|
||||
|
||||
class QueryContextCacheLoader: # pylint: disable=too-few-public-methods
|
||||
@staticmethod
|
||||
def load(cache_key: str) -> Dict[str, Any]:
|
||||
def load(cache_key: str) -> dict[str, Any]:
|
||||
cache_value = cache.get(cache_key)
|
||||
if not cache_value:
|
||||
raise ChartDataCacheLoadError("Cached data not found")
|
||||
|
||||
Reference in New Issue
Block a user