mirror of
https://github.com/apache/superset.git
synced 2026-04-07 18:35:15 +00:00
chore(pre-commit): Add pyupgrade and pycln hooks (#24197)
This commit is contained in:
@@ -24,8 +24,9 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Dict, Iterable, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from sqlalchemy.types import TypeEngine
|
||||
|
||||
@@ -33,14 +34,14 @@ from sqlalchemy.types import TypeEngine
|
||||
@dataclass
|
||||
class TableMetaData:
|
||||
table_name: str
|
||||
types: Optional[Dict[str, TypeEngine]]
|
||||
types: Optional[dict[str, TypeEngine]]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Table:
|
||||
table_name: str
|
||||
table_metadata: TableMetaData
|
||||
data: Iterable[Dict[Any, Any]]
|
||||
data: Iterable[dict[Any, Any]]
|
||||
|
||||
|
||||
class TableMetaDataFactory(ABC):
|
||||
@@ -48,6 +49,6 @@ class TableMetaDataFactory(ABC):
|
||||
def make(self) -> TableMetaData:
|
||||
...
|
||||
|
||||
def make_table(self, data: Iterable[Dict[Any, Any]]) -> Table:
|
||||
def make_table(self, data: Iterable[dict[Any, Any]]) -> Table:
|
||||
metadata = self.make()
|
||||
return Table(metadata.table_name, metadata, data)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pandas import DataFrame
|
||||
from sqlalchemy.inspection import inspect
|
||||
@@ -63,10 +63,10 @@ class PandasDataLoader(DataLoader):
|
||||
schema=self._detect_schema_name(),
|
||||
)
|
||||
|
||||
def _detect_schema_name(self) -> Optional[str]:
|
||||
def _detect_schema_name(self) -> str | None:
|
||||
return inspect(self._db_engine).default_schema_name
|
||||
|
||||
def _take_data_types(self, table: Table) -> Optional[Dict[str, str]]:
|
||||
def _take_data_types(self, table: Table) -> dict[str, str] | None:
|
||||
if metadata_table := table.table_metadata:
|
||||
types = metadata_table.types
|
||||
if types:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# under the License.
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
default_pandas_data_loader_config = {
|
||||
"if_exists": "replace",
|
||||
@@ -54,7 +54,7 @@ class PandasLoaderConfigurations:
|
||||
self.support_datetime_type = support_datetime_type
|
||||
|
||||
@classmethod
|
||||
def make_from_dict(cls, _dict: Dict[str, Any]) -> PandasLoaderConfigurations:
|
||||
def make_from_dict(cls, _dict: dict[str, Any]) -> PandasLoaderConfigurations:
|
||||
copy_dict = default_pandas_data_loader_config.copy()
|
||||
copy_dict.update(_dict)
|
||||
return PandasLoaderConfigurations(**copy_dict) # type: ignore
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# under the License.
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pandas import DataFrame
|
||||
|
||||
@@ -30,10 +30,10 @@ if TYPE_CHECKING:
|
||||
@log
|
||||
class TableToDfConvertorImpl(TableToDfConvertor):
|
||||
convert_datetime_to_str: bool
|
||||
_time_format: Optional[str]
|
||||
_time_format: str | None
|
||||
|
||||
def __init__(
|
||||
self, convert_ds_to_datetime: bool, time_format: Optional[str] = None
|
||||
self, convert_ds_to_datetime: bool, time_format: str | None = None
|
||||
) -> None:
|
||||
self.convert_datetime_to_str = convert_ds_to_datetime
|
||||
self._time_format = time_format
|
||||
|
||||
Reference in New Issue
Block a user