From ac1d779a30ea8b009007b02b2bbb7cbe254ec16c Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Thu, 26 Aug 2021 20:30:41 +0300 Subject: [PATCH] chore(ci): bump pylint to 2.10.2 (#16463) --- .pylintrc | 3 +++ requirements/testing.in | 2 +- requirements/testing.txt | 6 +++--- superset/annotation_layers/annotations/api.py | 4 ++-- superset/annotation_layers/annotations/commands/create.py | 2 +- superset/annotation_layers/annotations/commands/update.py | 2 +- superset/annotation_layers/api.py | 4 ++-- superset/annotation_layers/commands/create.py | 2 +- superset/annotation_layers/commands/update.py | 2 +- superset/charts/commands/create.py | 2 +- superset/charts/commands/update.py | 2 +- superset/commands/utils.py | 2 +- superset/connectors/sqla/models.py | 4 +--- superset/dashboards/commands/create.py | 2 +- superset/databases/commands/create.py | 2 +- superset/databases/commands/update.py | 2 +- superset/datasets/commands/create.py | 2 +- superset/datasets/commands/update.py | 2 +- superset/datasets/dao.py | 2 +- superset/models/dashboard.py | 4 +--- superset/reports/commands/create.py | 2 +- superset/reports/commands/update.py | 2 +- superset/tasks/async_queries.py | 8 +++----- superset/utils/dict_import_export.py | 4 ++-- superset/utils/sqllab_execution_context.py | 4 ++-- superset/views/base_schemas.py | 2 +- 26 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.pylintrc b/.pylintrc index e3715334d1..0de47845e4 100644 --- a/.pylintrc +++ b/.pylintrc @@ -86,6 +86,9 @@ disable= missing-docstring, too-many-lines, duplicate-code, + unspecified-encoding, + # re-enable once this no longer raises false positives + too-many-instance-attributes [REPORTS] diff --git a/requirements/testing.in b/requirements/testing.in index 3355d71fa4..016ae845b9 100644 --- a/requirements/testing.in +++ b/requirements/testing.in @@ -28,7 +28,7 @@ openpyxl parameterized pyfakefs pyhive[presto]>=0.6.3 -pylint==2.6.0 +pylint==2.10.2 pytest pytest-cov statsd diff --git a/requirements/testing.txt b/requirements/testing.txt index ccbd88989e..68d96c9b9a 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -1,4 +1,4 @@ -# SHA1:5bfcfb5d0ab31dd532ce58caa2aab91d6807b123 +# SHA1:59e47200215ca4695f09e03a773e1a6f310f78da # # This file is autogenerated by pip-compile-multi # To update, run: @@ -11,7 +11,7 @@ # via -r requirements/base.in appnope==0.1.2 # via ipython -astroid==2.6.6 +astroid==2.7.2 # via pylint backcall==0.2.0 # via ipython @@ -71,7 +71,7 @@ pyhive[hive,presto]==0.6.4 # via # -r requirements/development.in # -r requirements/testing.in -pylint==2.9.6 +pylint==2.10.2 # via -r requirements/testing.in pytest==6.2.4 # via diff --git a/superset/annotation_layers/annotations/api.py b/superset/annotation_layers/annotations/api.py index 2e2f81fe27..49172a2bc2 100644 --- a/superset/annotation_layers/annotations/api.py +++ b/superset/annotation_layers/annotations/api.py @@ -381,7 +381,7 @@ class AnnotationRestApi(BaseSupersetModelRestApi): try: new_model = UpdateAnnotationCommand(g.user, annotation_id, item).run() return self.response(200, id=new_model.id, result=item) - except (AnnotationNotFoundError, AnnotationLayerNotFoundError) as ex: + except (AnnotationNotFoundError, AnnotationLayerNotFoundError): return self.response_404() except AnnotationInvalidError as ex: return self.response_422(message=ex.normalized_messages()) @@ -438,7 +438,7 @@ class AnnotationRestApi(BaseSupersetModelRestApi): try: DeleteAnnotationCommand(g.user, annotation_id).run() return self.response(200, message="OK") - except AnnotationNotFoundError as ex: + except AnnotationNotFoundError: return self.response_404() except AnnotationDeleteFailedError as ex: logger.error( diff --git a/superset/annotation_layers/annotations/commands/create.py b/superset/annotation_layers/annotations/commands/create.py index cbcb09a4c5..d745df121f 100644 --- a/superset/annotation_layers/annotations/commands/create.py +++ b/superset/annotation_layers/annotations/commands/create.py @@ -52,7 +52,7 @@ class CreateAnnotationCommand(BaseCommand): return annotation def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] layer_id: Optional[int] = self._properties.get("layer") start_dttm: Optional[datetime] = self._properties.get("start_dttm") end_dttm: Optional[datetime] = self._properties.get("end_dttm") diff --git a/superset/annotation_layers/annotations/commands/update.py b/superset/annotation_layers/annotations/commands/update.py index eb544344f1..ccf11b6536 100644 --- a/superset/annotation_layers/annotations/commands/update.py +++ b/superset/annotation_layers/annotations/commands/update.py @@ -56,7 +56,7 @@ class UpdateAnnotationCommand(BaseCommand): return annotation def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] layer_id: Optional[int] = self._properties.get("layer") short_descr: str = self._properties.get("short_descr", "") diff --git a/superset/annotation_layers/api.py b/superset/annotation_layers/api.py index f43b385544..bba34e2fa8 100644 --- a/superset/annotation_layers/api.py +++ b/superset/annotation_layers/api.py @@ -149,7 +149,7 @@ class AnnotationLayerRestApi(BaseSupersetModelRestApi): try: DeleteAnnotationLayerCommand(g.user, pk).run() return self.response(200, message="OK") - except AnnotationLayerNotFoundError as ex: + except AnnotationLayerNotFoundError: return self.response_404() except AnnotationLayerDeleteIntegrityError as ex: return self.response_422(message=str(ex)) @@ -288,7 +288,7 @@ class AnnotationLayerRestApi(BaseSupersetModelRestApi): try: new_model = UpdateAnnotationLayerCommand(g.user, pk, item).run() return self.response(200, id=new_model.id, result=item) - except (AnnotationLayerNotFoundError) as ex: + except AnnotationLayerNotFoundError: return self.response_404() except AnnotationLayerInvalidError as ex: return self.response_422(message=ex.normalized_messages()) diff --git a/superset/annotation_layers/commands/create.py b/superset/annotation_layers/commands/create.py index 5e26bc49d4..ee42ce7557 100644 --- a/superset/annotation_layers/commands/create.py +++ b/superset/annotation_layers/commands/create.py @@ -48,7 +48,7 @@ class CreateAnnotationLayerCommand(BaseCommand): return annotation_layer def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] name = self._properties.get("name", "") diff --git a/superset/annotation_layers/commands/update.py b/superset/annotation_layers/commands/update.py index 7e8f6d5bd7..d2f48abb24 100644 --- a/superset/annotation_layers/commands/update.py +++ b/superset/annotation_layers/commands/update.py @@ -52,7 +52,7 @@ class UpdateAnnotationLayerCommand(BaseCommand): return annotation_layer def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] name = self._properties.get("name", "") self._model = AnnotationLayerDAO.find_by_id(self._model_id) diff --git a/superset/charts/commands/create.py b/superset/charts/commands/create.py index 36dca581a7..34a25aea2d 100644 --- a/superset/charts/commands/create.py +++ b/superset/charts/commands/create.py @@ -53,7 +53,7 @@ class CreateChartCommand(CreateMixin, BaseCommand): return chart def validate(self) -> None: - exceptions = list() + exceptions = [] datasource_type = self._properties["datasource_type"] datasource_id = self._properties["datasource_id"] dashboard_ids = self._properties.get("dashboards", []) diff --git a/superset/charts/commands/update.py b/superset/charts/commands/update.py index c63d0bccca..0355e6e5ff 100644 --- a/superset/charts/commands/update.py +++ b/superset/charts/commands/update.py @@ -68,7 +68,7 @@ class UpdateChartCommand(UpdateMixin, BaseCommand): return chart def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] dashboard_ids = self._properties.get("dashboards") owner_ids: Optional[List[int]] = self._properties.get("owners") diff --git a/superset/commands/utils.py b/superset/commands/utils.py index c656ce3040..070039874e 100644 --- a/superset/commands/utils.py +++ b/superset/commands/utils.py @@ -41,7 +41,7 @@ def populate_owners( :returns: Final list of owners """ owner_ids = owner_ids or [] - owners = list() + owners = [] if not owner_ids and default_to_user: return [user] if user.id not in owner_ids and "admin" not in [ diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 23ff4bb8dd..33bacc6be5 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -471,9 +471,7 @@ sqlatable_user = Table( ) -class SqlaTable( - Model, BaseDatasource -): # pylint: disable=too-many-instance-attributes,too-many-public-methods +class SqlaTable(Model, BaseDatasource): # pylint: disable=too-many-public-methods """An ORM object for SqlAlchemy table references""" type = "table" diff --git a/superset/dashboards/commands/create.py b/superset/dashboards/commands/create.py index 91f7e90bac..1e796bc318 100644 --- a/superset/dashboards/commands/create.py +++ b/superset/dashboards/commands/create.py @@ -50,7 +50,7 @@ class CreateDashboardCommand(CreateMixin, BaseCommand): return dashboard def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] owner_ids: Optional[List[int]] = self._properties.get("owners") role_ids: Optional[List[int]] = self._properties.get("roles") slug: str = self._properties.get("slug", "") diff --git a/superset/databases/commands/create.py b/superset/databases/commands/create.py index 6024b64469..ffcb018c06 100644 --- a/superset/databases/commands/create.py +++ b/superset/databases/commands/create.py @@ -77,7 +77,7 @@ class CreateDatabaseCommand(BaseCommand): return database def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] sqlalchemy_uri: Optional[str] = self._properties.get("sqlalchemy_uri") database_name: Optional[str] = self._properties.get("database_name") if not sqlalchemy_uri: diff --git a/superset/databases/commands/update.py b/superset/databases/commands/update.py index db1741c32b..69b6c30e71 100644 --- a/superset/databases/commands/update.py +++ b/superset/databases/commands/update.py @@ -69,7 +69,7 @@ class UpdateDatabaseCommand(BaseCommand): return database def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] # Validate/populate model exists self._model = DatabaseDAO.find_by_id(self._model_id) if not self._model: diff --git a/superset/datasets/commands/create.py b/superset/datasets/commands/create.py index 0bf403ebfb..4a89b1a818 100644 --- a/superset/datasets/commands/create.py +++ b/superset/datasets/commands/create.py @@ -66,7 +66,7 @@ class CreateDatasetCommand(CreateMixin, BaseCommand): return dataset def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] database_id = self._properties["database"] table_name = self._properties["table_name"] schema = self._properties.get("schema", None) diff --git a/superset/datasets/commands/update.py b/superset/datasets/commands/update.py index c9bf8500c9..cb1016c7a0 100644 --- a/superset/datasets/commands/update.py +++ b/superset/datasets/commands/update.py @@ -76,7 +76,7 @@ class UpdateDatasetCommand(UpdateMixin, BaseCommand): raise DatasetUpdateFailedError() def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] owner_ids: Optional[List[int]] = self._properties.get("owners") # Validate/populate model exists self._model = DatasetDAO.find_by_id(self._model_id) diff --git a/superset/datasets/dao.py b/superset/datasets/dao.py index db7bbe04f5..8aee37bbe1 100644 --- a/superset/datasets/dao.py +++ b/superset/datasets/dao.py @@ -219,7 +219,7 @@ class DatasetDAO(BaseDAO): # pylint: disable=too-many-public-methods - If there are extra metrics on the metadata db that are not defined on the List then we delete. """ - new_metrics = list() + new_metrics = [] for metric in property_metrics: metric_id = metric.get("id") if metric.get("id"): diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py index 11fc26d2c9..3b15841d70 100644 --- a/superset/models/dashboard.py +++ b/superset/models/dashboard.py @@ -129,9 +129,7 @@ DashboardRoles = Table( ) -class Dashboard( # pylint: disable=too-many-instance-attributes - Model, AuditMixinNullable, ImportExportMixin -): +class Dashboard(Model, AuditMixinNullable, ImportExportMixin): """The dashboard object!""" __tablename__ = "dashboards" diff --git a/superset/reports/commands/create.py b/superset/reports/commands/create.py index 23ed27e89c..b260fb9b5f 100644 --- a/superset/reports/commands/create.py +++ b/superset/reports/commands/create.py @@ -55,7 +55,7 @@ class CreateReportScheduleCommand(CreateMixin, BaseReportScheduleCommand): return report_schedule def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] owner_ids: Optional[List[int]] = self._properties.get("owners") name = self._properties.get("name", "") report_type = self._properties.get("type") diff --git a/superset/reports/commands/update.py b/superset/reports/commands/update.py index c1dd416790..a38ca983e8 100644 --- a/superset/reports/commands/update.py +++ b/superset/reports/commands/update.py @@ -59,7 +59,7 @@ class UpdateReportScheduleCommand(UpdateMixin, BaseReportScheduleCommand): return report_schedule def validate(self) -> None: - exceptions: List[ValidationError] = list() + exceptions: List[ValidationError] = [] owner_ids: Optional[List[int]] = self._properties.get("owners") report_type = self._properties.get("type", ReportScheduleType.ALERT) diff --git a/superset/tasks/async_queries.py b/superset/tasks/async_queries.py index d2df6dd617..19fbef297a 100644 --- a/superset/tasks/async_queries.py +++ b/superset/tasks/async_queries.py @@ -68,7 +68,7 @@ def load_chart_data_into_cache( raise exc except Exception as exc: # TODO: QueryContext should support SIP-40 style errors - error = exc.message if hasattr(exc, "message") else str(exc) # type: ignore # pylint: disable=no-member + error = exc.message if hasattr(exc, "message") else str(exc) # type: ignore errors = [{"message": error}] async_query_manager.update_job( job_metadata, async_query_manager.STATUS_ERROR, errors=errors @@ -122,11 +122,9 @@ def load_explore_json_into_cache( # pylint: disable=too-many-locals raise ex except Exception as exc: if isinstance(exc, SupersetVizException): - errors = exc.errors # pylint: disable=no-member + errors = exc.errors else: - error = ( - exc.message if hasattr(exc, "message") else str(exc) # type: ignore # pylint: disable=no-member - ) + error = exc.message if hasattr(exc, "message") else str(exc) # type: ignore errors = [error] async_query_manager.update_job( diff --git a/superset/utils/dict_import_export.py b/superset/utils/dict_import_export.py index 256f1b5655..1924d59642 100644 --- a/superset/utils/dict_import_export.py +++ b/superset/utils/dict_import_export.py @@ -36,7 +36,7 @@ def export_schema_to_dict(back_references: bool) -> Dict[str, Any]: clusters = [ DruidCluster.export_schema(recursive=True, include_parent_ref=back_references) ] - data = dict() + data = {} if databases: data[DATABASES_KEY] = databases if clusters: @@ -69,7 +69,7 @@ def export_to_dict( for cluster in cls ] logger.info("Exported %d %s", len(clusters), DRUID_CLUSTERS_KEY) - data = dict() + data = {} if databases: data[DATABASES_KEY] = databases if clusters: diff --git a/superset/utils/sqllab_execution_context.py b/superset/utils/sqllab_execution_context.py index fc46552013..2aeb520c30 100644 --- a/superset/utils/sqllab_execution_context.py +++ b/superset/utils/sqllab_execution_context.py @@ -33,8 +33,8 @@ logger = logging.getLogger(__name__) SqlResults = Dict[str, Any] -@dataclass # pylint: disable=R0902 -class SqlJsonExecutionContext: +@dataclass +class SqlJsonExecutionContext: # pylint: disable=too-many-instance-attributes database_id: int schema: str sql: str diff --git a/superset/views/base_schemas.py b/superset/views/base_schemas.py index de39e71027..b7ffc72223 100644 --- a/superset/views/base_schemas.py +++ b/superset/views/base_schemas.py @@ -112,7 +112,7 @@ class BaseOwnedSchema(BaseSupersetSchema): @staticmethod def set_owners(instance: Model, owners: List[int]) -> None: - owner_objs = list() + owner_objs = [] if g.user.get_id() not in owners: owners.append(g.user.get_id()) for owner_id in owners: