mirror of
https://github.com/apache/superset.git
synced 2026-04-24 18:44:53 +00:00
chore(pre-commit): Add pyupgrade and pycln hooks (#24197)
This commit is contained in:
@@ -24,7 +24,8 @@ addition to a table, new models for columns, metrics, and datasets were also int
|
||||
These models are not fully implemented, and shouldn't be used yet.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, Iterable, List, Optional, TYPE_CHECKING
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Optional, TYPE_CHECKING
|
||||
|
||||
import sqlalchemy as sa
|
||||
from flask_appbuilder import Model
|
||||
@@ -87,7 +88,7 @@ class Table(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
|
||||
# The relationship between datasets and columns is 1:n, but we use a
|
||||
# many-to-many association table to avoid adding two mutually exclusive
|
||||
# columns(dataset_id and table_id) to Column
|
||||
columns: List[Column] = relationship(
|
||||
columns: list[Column] = relationship(
|
||||
"Column",
|
||||
secondary=table_column_association_table,
|
||||
cascade="all, delete-orphan",
|
||||
@@ -96,7 +97,7 @@ class Table(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
|
||||
# is loaded.
|
||||
backref="tables",
|
||||
)
|
||||
datasets: List["Dataset"] # will be populated by Dataset.tables backref
|
||||
datasets: list["Dataset"] # will be populated by Dataset.tables backref
|
||||
|
||||
# We use ``sa.Text`` for these attributes because (1) in modern databases the
|
||||
# performance is the same as ``VARCHAR``[1] and (2) because some table names can be
|
||||
@@ -130,7 +131,7 @@ class Table(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
|
||||
existing_columns = {column.name: column for column in self.columns}
|
||||
quote_identifier = self.database.quote_identifier
|
||||
|
||||
def update_or_create_column(column_meta: Dict[str, Any]) -> Column:
|
||||
def update_or_create_column(column_meta: dict[str, Any]) -> Column:
|
||||
column_name: str = column_meta["name"]
|
||||
if column_name in existing_columns:
|
||||
column = existing_columns[column_name]
|
||||
@@ -153,8 +154,8 @@ class Table(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
|
||||
table_names: Iterable[TableName],
|
||||
default_schema: Optional[str] = None,
|
||||
sync_columns: Optional[bool] = False,
|
||||
default_props: Optional[Dict[str, Any]] = None,
|
||||
) -> List["Table"]:
|
||||
default_props: Optional[dict[str, Any]] = None,
|
||||
) -> list["Table"]:
|
||||
"""
|
||||
Load or create multiple Table instances.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user