chore(pre-commit): Add pyupgrade and pycln hooks (#24197)

This commit is contained in:
John Bodley
2023-06-01 12:01:10 -07:00
committed by GitHub
parent 7d7ce63970
commit a4d5d7c6b9
448 changed files with 3084 additions and 3305 deletions

View File

@@ -18,7 +18,7 @@ import logging
import sys
from datetime import datetime
from pathlib import Path
from typing import List, Optional
from typing import Optional
from zipfile import is_zipfile, ZipFile
import click
@@ -309,7 +309,7 @@ else:
from superset.dashboards.commands.importers.v0 import ImportDashboardsCommand
path_object = Path(path)
files: List[Path] = []
files: list[Path] = []
if path_object.is_file():
files.append(path_object)
elif path_object.exists() and not recursive:
@@ -363,7 +363,7 @@ else:
sync_metrics = "metrics" in sync_array
path_object = Path(path)
files: List[Path] = []
files: list[Path] = []
if path_object.is_file():
files.append(path_object)
elif path_object.exists() and not recursive:

View File

@@ -18,7 +18,7 @@
import importlib
import logging
import pkgutil
from typing import Any, Dict
from typing import Any
import click
from colorama import Fore, Style
@@ -40,7 +40,7 @@ def superset() -> None:
"""This is a management script for the Superset application."""
@app.shell_context_processor
def make_shell_context() -> Dict[str, Any]:
def make_shell_context() -> dict[str, Any]:
return dict(app=app, db=db)
@@ -79,5 +79,5 @@ def version(verbose: bool) -> None:
)
print(Fore.BLUE + "-=" * 15)
if verbose:
print("[DB] : " + "{}".format(db.engine))
print("[DB] : " + f"{db.engine}")
print(Style.RESET_ALL)

View File

@@ -17,7 +17,6 @@
import json
from copy import deepcopy
from textwrap import dedent
from typing import Set, Tuple
import click
from click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup
@@ -102,7 +101,7 @@ def native_filters() -> None:
)
def upgrade(
all_: bool, # pylint: disable=unused-argument
dashboard_ids: Tuple[int, ...],
dashboard_ids: tuple[int, ...],
) -> None:
"""
Upgrade legacy filter-box charts to native dashboard filters.
@@ -251,7 +250,7 @@ def upgrade(
)
def downgrade(
all_: bool, # pylint: disable=unused-argument
dashboard_ids: Tuple[int, ...],
dashboard_ids: tuple[int, ...],
) -> None:
"""
Downgrade native dashboard filters to legacy filter-box charts (where applicable).
@@ -347,7 +346,7 @@ def downgrade(
)
def cleanup(
all_: bool, # pylint: disable=unused-argument
dashboard_ids: Tuple[int, ...],
dashboard_ids: tuple[int, ...],
) -> None:
"""
Cleanup obsolete legacy filter-box charts and interim metadata.
@@ -355,7 +354,7 @@ def cleanup(
Note this operation is irreversible.
"""
slice_ids: Set[int] = set()
slice_ids: set[int] = set()
# Cleanup the dashboard which contains legacy fields used for downgrading.
for dashboard in (

View File

@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import logging
from typing import Type, Union
from typing import Union
import click
from celery.utils.abstract import CallableTask
@@ -75,7 +75,7 @@ def compute_thumbnails(
def compute_generic_thumbnail(
friendly_type: str,
model_cls: Union[Type[Dashboard], Type[Slice]],
model_cls: Union[type[Dashboard], type[Slice]],
model_id: int,
compute_func: CallableTask,
) -> None: