mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
style(mypy): Spit-and-polish pass (#10001)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from flask_appbuilder.models.sqla import Model
|
||||
from flask_appbuilder.security.sqla.models import User
|
||||
@@ -39,7 +39,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CreateDatasetCommand(BaseCommand):
|
||||
def __init__(self, user: User, data: Dict):
|
||||
def __init__(self, user: User, data: Dict[str, Any]):
|
||||
self._actor = user
|
||||
self._properties = data.copy()
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# under the License.
|
||||
import logging
|
||||
from collections import Counter
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from flask_appbuilder.models.sqla import Model
|
||||
from flask_appbuilder.security.sqla.models import User
|
||||
@@ -48,7 +48,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class UpdateDatasetCommand(BaseCommand):
|
||||
def __init__(self, user: User, model_id: int, data: Dict):
|
||||
def __init__(self, user: User, model_id: int, data: Dict[str, Any]):
|
||||
self._actor = user
|
||||
self._model_id = model_id
|
||||
self._properties = data.copy()
|
||||
@@ -111,7 +111,7 @@ class UpdateDatasetCommand(BaseCommand):
|
||||
raise exception
|
||||
|
||||
def _validate_columns(
|
||||
self, columns: List[Dict], exceptions: List[ValidationError]
|
||||
self, columns: List[Dict[str, Any]], exceptions: List[ValidationError]
|
||||
) -> None:
|
||||
# Validate duplicates on data
|
||||
if self._get_duplicates(columns, "column_name"):
|
||||
@@ -133,7 +133,7 @@ class UpdateDatasetCommand(BaseCommand):
|
||||
exceptions.append(DatasetColumnsExistsValidationError())
|
||||
|
||||
def _validate_metrics(
|
||||
self, metrics: List[Dict], exceptions: List[ValidationError]
|
||||
self, metrics: List[Dict[str, Any]], exceptions: List[ValidationError]
|
||||
) -> None:
|
||||
if self._get_duplicates(metrics, "metric_name"):
|
||||
exceptions.append(DatasetMetricsDuplicateValidationError())
|
||||
@@ -152,7 +152,7 @@ class UpdateDatasetCommand(BaseCommand):
|
||||
exceptions.append(DatasetMetricsExistsValidationError())
|
||||
|
||||
@staticmethod
|
||||
def _get_duplicates(data: List[Dict], key: str) -> List[str]:
|
||||
def _get_duplicates(data: List[Dict[str, Any]], key: str) -> List[str]:
|
||||
duplicates = [
|
||||
name
|
||||
for name, count in Counter([item[key] for item in data]).items()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from flask import current_app
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
@@ -116,7 +116,7 @@ class DatasetDAO(BaseDAO):
|
||||
|
||||
@classmethod
|
||||
def update(
|
||||
cls, model: SqlaTable, properties: Dict, commit: bool = True
|
||||
cls, model: SqlaTable, properties: Dict[str, Any], commit: bool = True
|
||||
) -> Optional[SqlaTable]:
|
||||
"""
|
||||
Updates a Dataset model on the metadata DB
|
||||
@@ -151,13 +151,13 @@ class DatasetDAO(BaseDAO):
|
||||
|
||||
@classmethod
|
||||
def update_column(
|
||||
cls, model: TableColumn, properties: Dict, commit: bool = True
|
||||
cls, model: TableColumn, properties: Dict[str, Any], commit: bool = True
|
||||
) -> Optional[TableColumn]:
|
||||
return DatasetColumnDAO.update(model, properties, commit=commit)
|
||||
|
||||
@classmethod
|
||||
def create_column(
|
||||
cls, properties: Dict, commit: bool = True
|
||||
cls, properties: Dict[str, Any], commit: bool = True
|
||||
) -> Optional[TableColumn]:
|
||||
"""
|
||||
Creates a Dataset model on the metadata DB
|
||||
@@ -166,13 +166,13 @@ class DatasetDAO(BaseDAO):
|
||||
|
||||
@classmethod
|
||||
def update_metric(
|
||||
cls, model: SqlMetric, properties: Dict, commit: bool = True
|
||||
cls, model: SqlMetric, properties: Dict[str, Any], commit: bool = True
|
||||
) -> Optional[SqlMetric]:
|
||||
return DatasetMetricDAO.update(model, properties, commit=commit)
|
||||
|
||||
@classmethod
|
||||
def create_metric(
|
||||
cls, properties: Dict, commit: bool = True
|
||||
cls, properties: Dict[str, Any], commit: bool = True
|
||||
) -> Optional[SqlMetric]:
|
||||
"""
|
||||
Creates a Dataset model on the metadata DB
|
||||
|
||||
Reference in New Issue
Block a user