mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore(pre-commit): Add pyupgrade and pycln hooks (#24197)
This commit is contained in:
@@ -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 Callable, List, Optional
|
||||
from typing import Callable, Optional
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -93,7 +93,7 @@ def _create_table(
|
||||
return table
|
||||
|
||||
|
||||
def _cleanup(dash_id: int, slice_ids: List[int]) -> None:
|
||||
def _cleanup(dash_id: int, slice_ids: list[int]) -> None:
|
||||
schema = get_example_default_schema()
|
||||
for datasource in db.session.query(SqlaTable).filter_by(
|
||||
table_name="birth_names", schema=schema
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Fixtures for test_datasource.py"""
|
||||
from typing import Any, Dict, Generator
|
||||
from collections.abc import Generator
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import Column, create_engine, Date, Integer, MetaData, String, Table
|
||||
@@ -31,7 +32,7 @@ from superset.utils.database import get_example_database
|
||||
from tests.integration_tests.test_app import app
|
||||
|
||||
|
||||
def get_datasource_post() -> Dict[str, Any]:
|
||||
def get_datasource_post() -> dict[str, Any]:
|
||||
schema = get_example_default_schema()
|
||||
|
||||
return {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import random
|
||||
from typing import Dict, List, Set
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
@@ -29,7 +28,7 @@ from superset.utils.database import get_example_database
|
||||
from tests.integration_tests.dashboard_utils import create_slice, create_table_metadata
|
||||
from tests.integration_tests.test_app import app
|
||||
|
||||
misc_dash_slices: Set[str] = set()
|
||||
misc_dash_slices: set[str] = set()
|
||||
|
||||
|
||||
ENERGY_USAGE_TBL_NAME = "energy_usage"
|
||||
@@ -70,7 +69,7 @@ def _get_dataframe():
|
||||
return pd.DataFrame.from_dict(data)
|
||||
|
||||
|
||||
def _create_energy_table() -> List[Slice]:
|
||||
def _create_energy_table() -> list[Slice]:
|
||||
table = create_table_metadata(
|
||||
table_name=ENERGY_USAGE_TBL_NAME,
|
||||
database=get_example_database(),
|
||||
@@ -100,7 +99,7 @@ def _create_energy_table() -> List[Slice]:
|
||||
|
||||
|
||||
def _create_and_commit_energy_slice(
|
||||
table: SqlaTable, title: str, viz_type: str, param: Dict[str, str]
|
||||
table: SqlaTable, title: str, viz_type: str, param: dict[str, str]
|
||||
):
|
||||
slice = create_slice(title, viz_type, table, param)
|
||||
existing_slice = (
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any
|
||||
|
||||
# example V0 import/export format
|
||||
dataset_ui_export: List[Dict[str, Any]] = [
|
||||
dataset_ui_export: list[dict[str, Any]] = [
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
@@ -48,7 +48,7 @@ dataset_ui_export: List[Dict[str, Any]] = [
|
||||
}
|
||||
]
|
||||
|
||||
dataset_cli_export: Dict[str, Any] = {
|
||||
dataset_cli_export: dict[str, Any] = {
|
||||
"databases": [
|
||||
{
|
||||
"allow_run_async": True,
|
||||
@@ -59,7 +59,7 @@ dataset_cli_export: Dict[str, Any] = {
|
||||
]
|
||||
}
|
||||
|
||||
dashboard_export: Dict[str, Any] = {
|
||||
dashboard_export: dict[str, Any] = {
|
||||
"dashboards": [
|
||||
{
|
||||
"__Dashboard__": {
|
||||
@@ -318,35 +318,35 @@ dashboard_export: Dict[str, Any] = {
|
||||
}
|
||||
|
||||
# example V1 import/export format
|
||||
database_metadata_config: Dict[str, Any] = {
|
||||
database_metadata_config: dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
"type": "Database",
|
||||
"timestamp": "2020-11-04T21:27:44.423819+00:00",
|
||||
}
|
||||
|
||||
dataset_metadata_config: Dict[str, Any] = {
|
||||
dataset_metadata_config: dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
"type": "SqlaTable",
|
||||
"timestamp": "2020-11-04T21:27:44.423819+00:00",
|
||||
}
|
||||
|
||||
chart_metadata_config: Dict[str, Any] = {
|
||||
chart_metadata_config: dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
"type": "Slice",
|
||||
"timestamp": "2020-11-04T21:27:44.423819+00:00",
|
||||
}
|
||||
|
||||
dashboard_metadata_config: Dict[str, Any] = {
|
||||
dashboard_metadata_config: dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
"type": "Dashboard",
|
||||
"timestamp": "2020-11-04T21:27:44.423819+00:00",
|
||||
}
|
||||
saved_queries_metadata_config: Dict[str, Any] = {
|
||||
saved_queries_metadata_config: dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
"type": "SavedQuery",
|
||||
"timestamp": "2021-03-30T20:37:54.791187+00:00",
|
||||
}
|
||||
database_config: Dict[str, Any] = {
|
||||
database_config: dict[str, Any] = {
|
||||
"allow_csv_upload": True,
|
||||
"allow_ctas": True,
|
||||
"allow_cvas": True,
|
||||
@@ -361,7 +361,7 @@ database_config: Dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
||||
database_with_ssh_tunnel_config_private_key: Dict[str, Any] = {
|
||||
database_with_ssh_tunnel_config_private_key: dict[str, Any] = {
|
||||
"allow_csv_upload": True,
|
||||
"allow_ctas": True,
|
||||
"allow_cvas": True,
|
||||
@@ -383,7 +383,7 @@ database_with_ssh_tunnel_config_private_key: Dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
||||
database_with_ssh_tunnel_config_password: Dict[str, Any] = {
|
||||
database_with_ssh_tunnel_config_password: dict[str, Any] = {
|
||||
"allow_csv_upload": True,
|
||||
"allow_ctas": True,
|
||||
"allow_cvas": True,
|
||||
@@ -404,7 +404,7 @@ database_with_ssh_tunnel_config_password: Dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
||||
database_with_ssh_tunnel_config_no_credentials: Dict[str, Any] = {
|
||||
database_with_ssh_tunnel_config_no_credentials: dict[str, Any] = {
|
||||
"allow_csv_upload": True,
|
||||
"allow_ctas": True,
|
||||
"allow_cvas": True,
|
||||
@@ -424,7 +424,7 @@ database_with_ssh_tunnel_config_no_credentials: Dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
||||
database_with_ssh_tunnel_config_mix_credentials: Dict[str, Any] = {
|
||||
database_with_ssh_tunnel_config_mix_credentials: dict[str, Any] = {
|
||||
"allow_csv_upload": True,
|
||||
"allow_ctas": True,
|
||||
"allow_cvas": True,
|
||||
@@ -446,7 +446,7 @@ database_with_ssh_tunnel_config_mix_credentials: Dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
||||
database_with_ssh_tunnel_config_private_pass_only: Dict[str, Any] = {
|
||||
database_with_ssh_tunnel_config_private_pass_only: dict[str, Any] = {
|
||||
"allow_csv_upload": True,
|
||||
"allow_ctas": True,
|
||||
"allow_cvas": True,
|
||||
@@ -468,7 +468,7 @@ database_with_ssh_tunnel_config_private_pass_only: Dict[str, Any] = {
|
||||
}
|
||||
|
||||
|
||||
dataset_config: Dict[str, Any] = {
|
||||
dataset_config: dict[str, Any] = {
|
||||
"table_name": "imported_dataset",
|
||||
"main_dttm_col": None,
|
||||
"description": "This is a dataset that was exported",
|
||||
@@ -513,7 +513,7 @@ dataset_config: Dict[str, Any] = {
|
||||
"database_uuid": "b8a1ccd3-779d-4ab7-8ad8-9ab119d7fe89",
|
||||
}
|
||||
|
||||
chart_config: Dict[str, Any] = {
|
||||
chart_config: dict[str, Any] = {
|
||||
"slice_name": "Deck Path",
|
||||
"viz_type": "deck_path",
|
||||
"params": {
|
||||
@@ -557,7 +557,7 @@ chart_config: Dict[str, Any] = {
|
||||
"dataset_uuid": "10808100-158b-42c4-842e-f32b99d88dfb",
|
||||
}
|
||||
|
||||
dashboard_config: Dict[str, Any] = {
|
||||
dashboard_config: dict[str, Any] = {
|
||||
"dashboard_title": "Test dash",
|
||||
"description": None,
|
||||
"css": "",
|
||||
|
||||
@@ -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, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from tests.common.query_context_generator import QueryContextGenerator
|
||||
from tests.integration_tests.base_tests import SupersetTestCase
|
||||
@@ -29,8 +29,8 @@ def get_query_context(
|
||||
query_name: str,
|
||||
add_postprocessing_operations: bool = False,
|
||||
add_time_offsets: bool = False,
|
||||
form_data: Optional[Dict[str, Any]] = None,
|
||||
) -> Dict[str, Any]:
|
||||
form_data: Optional[dict[str, Any]] = None,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
Create a request payload for retrieving a QueryContext object via the
|
||||
`api/v1/chart/data` endpoint. By default returns a payload corresponding to one
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import json
|
||||
import string
|
||||
from random import choice, randint, random, uniform
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
@@ -94,7 +94,7 @@ def create_dashboard_for_loaded_data():
|
||||
return dash_id_to_delete, slices_ids_to_delete
|
||||
|
||||
|
||||
def _create_world_bank_slices(table: SqlaTable) -> List[Slice]:
|
||||
def _create_world_bank_slices(table: SqlaTable) -> list[Slice]:
|
||||
from superset.examples.world_bank import create_slices
|
||||
|
||||
slices = create_slices(table)
|
||||
@@ -102,7 +102,7 @@ def _create_world_bank_slices(table: SqlaTable) -> List[Slice]:
|
||||
return slices
|
||||
|
||||
|
||||
def _commit_slices(slices: List[Slice]):
|
||||
def _commit_slices(slices: list[Slice]):
|
||||
for slice in slices:
|
||||
o = db.session.query(Slice).filter_by(slice_name=slice.slice_name).one_or_none()
|
||||
if o:
|
||||
@@ -128,7 +128,7 @@ def _create_world_bank_dashboard(table: SqlaTable) -> Dashboard:
|
||||
return dash
|
||||
|
||||
|
||||
def _cleanup(dash_id: int, slices_ids: List[int]) -> None:
|
||||
def _cleanup(dash_id: int, slices_ids: list[int]) -> None:
|
||||
dash = db.session.query(Dashboard).filter_by(id=dash_id).first()
|
||||
db.session.delete(dash)
|
||||
for slice_id in slices_ids:
|
||||
@@ -148,7 +148,7 @@ def _get_dataframe(database: Database) -> DataFrame:
|
||||
return df
|
||||
|
||||
|
||||
def _get_world_bank_data() -> List[Dict[Any, Any]]:
|
||||
def _get_world_bank_data() -> list[dict[Any, Any]]:
|
||||
data = []
|
||||
for _ in range(100):
|
||||
data.append(
|
||||
|
||||
Reference in New Issue
Block a user