chore(pylint): Remove top-level disable (#16589)

* chore(pylint): Remove top-level disable

* Update examples.py

* Update command.py

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley 2021-09-15 09:30:23 -07:00 committed by GitHub
parent adc3d24c21
commit fb4650a6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 681 additions and 655 deletions

View File

@ -120,7 +120,7 @@ evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / stateme
[BASIC]
# Good variable names which should always be accepted, separated by a comma
good-names=_,df,ex,f,i,id,j,k,l,o,pk,Run,ts,v,x
good-names=_,df,ex,f,i,id,j,k,l,o,pk,Run,ts,v,x,y
# Bad variable names which should always be refused, separated by a comma
bad-names=fd,foo,bar,baz,toto,tutu,tata

View File

@ -13,9 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=no-value-for-parameter
import csv as lib_csv
import os
import re

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=protected-access
from typing import Any, Dict, List, Set, Tuple
from marshmallow import Schema
@ -78,6 +76,7 @@ class ImportExamplesCommand(ImportModelsCommand):
@classmethod
def _get_uuids(cls) -> Set[str]:
# pylint: disable=protected-access
return (
ImportDatabasesCommand._get_uuids()
| ImportDatasetsCommand._get_uuids()
@ -85,9 +84,8 @@ class ImportExamplesCommand(ImportModelsCommand):
| ImportDashboardsCommand._get_uuids()
)
# pylint: disable=too-many-locals, arguments-differ
@staticmethod
def _import(
def _import( # pylint: disable=arguments-differ,too-many-locals
session: Session,
configs: Dict[str, Any],
overwrite: bool = False,

View File

@ -38,6 +38,7 @@ from dateutil import tz
from flask import Blueprint
from flask_appbuilder.security.manager import AUTH_DB
from pandas.io.parsers import STR_NA_VALUES
from werkzeug.local import LocalProxy
from superset.jinja_context import BaseTemplateProcessor
from superset.stats_logger import DummyStatsLogger
@ -178,9 +179,9 @@ SQLALCHEMY_CUSTOM_PASSWORD_STORE = None
# Note: the default impl leverages SqlAlchemyUtils' EncryptedType, which defaults
# to AES-128 under the covers using the app's SECRET_KEY as key material.
#
# pylint: disable=C0103
SQLALCHEMY_ENCRYPTED_FIELD_TYPE_ADAPTER = SQLAlchemyUtilsAdapter
SQLALCHEMY_ENCRYPTED_FIELD_TYPE_ADAPTER = ( # pylint: disable=invalid-name
SQLAlchemyUtilsAdapter
)
# The limit of queries fetched for query search
QUERY_SEARCH_LIMIT = 1000
@ -841,7 +842,7 @@ CSV_TO_HIVE_UPLOAD_S3_BUCKET = None
CSV_TO_HIVE_UPLOAD_DIRECTORY = "EXTERNAL_HIVE_TABLES/"
# Function that creates upload directory dynamically based on the
# database used, user and schema provided.
def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC(
def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC( # pylint: disable=invalid-name
database: "Database",
user: "models.User", # pylint: disable=unused-argument
schema: Optional[str],
@ -986,7 +987,14 @@ DB_CONNECTION_MUTATOR = None
# def SQL_QUERY_MUTATOR(sql, user_name, security_manager, database):
# dttm = datetime.now().isoformat()
# return f"-- [SQL LAB] {username} {dttm}\n{sql}"
SQL_QUERY_MUTATOR = None
def SQL_QUERY_MUTATOR( # pylint: disable=invalid-name,unused-argument
sql: str,
user_name: Optional[str],
security_manager: LocalProxy,
database: "Database",
) -> str:
return sql
# Enable / disable scheduled email reports
#

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-many-ancestors
import json
import logging
from datetime import datetime
@ -62,7 +61,9 @@ class EnsureEnabledMixin:
raise NotFound()
class DruidColumnInlineView(CompactCRUDMixin, EnsureEnabledMixin, SupersetModelView):
class DruidColumnInlineView( # pylint: disable=too-many-ancestors
CompactCRUDMixin, EnsureEnabledMixin, SupersetModelView,
):
datamodel = SQLAInterface(models.DruidColumn)
include_route_methods = RouteMethod.RELATED_VIEW_SET
@ -149,7 +150,9 @@ class DruidColumnInlineView(CompactCRUDMixin, EnsureEnabledMixin, SupersetModelV
self.post_update(item)
class DruidMetricInlineView(CompactCRUDMixin, EnsureEnabledMixin, SupersetModelView):
class DruidMetricInlineView( # pylint: disable=too-many-ancestors
CompactCRUDMixin, EnsureEnabledMixin, SupersetModelView,
):
datamodel = SQLAInterface(models.DruidMetric)
include_route_methods = RouteMethod.RELATED_VIEW_SET
@ -202,7 +205,7 @@ class DruidMetricInlineView(CompactCRUDMixin, EnsureEnabledMixin, SupersetModelV
edit_form_extra_fields = add_form_extra_fields
class DruidClusterModelView(
class DruidClusterModelView( # pylint: disable=too-many-ancestors
EnsureEnabledMixin, SupersetModelView, DeleteMixin, YamlExportMixin,
):
datamodel = SQLAInterface(models.DruidCluster)
@ -266,7 +269,7 @@ class DruidClusterModelView(
DeleteMixin._delete(self, pk)
class DruidDatasourceModelView(
class DruidDatasourceModelView( # pylint: disable=too-many-ancestors
EnsureEnabledMixin, DatasourceModelView, DeleteMixin, YamlExportMixin,
):
datamodel = SQLAInterface(models.DruidDatasource)

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-few-public-methods
from typing import Any, Optional
from flask_appbuilder.security.sqla.models import Role
@ -31,7 +29,7 @@ from superset.views.base import BaseFilter, get_user_roles, is_user_admin
from superset.views.base_api import BaseFavoriteFilter
class DashboardTitleOrSlugFilter(BaseFilter):
class DashboardTitleOrSlugFilter(BaseFilter): # pylint: disable=too-few-public-methods
name = _("Title or Slug")
arg_name = "title_or_slug"
@ -47,7 +45,9 @@ class DashboardTitleOrSlugFilter(BaseFilter):
)
class DashboardFavoriteFilter(BaseFavoriteFilter):
class DashboardFavoriteFilter( # pylint: disable=too-few-public-methods
BaseFavoriteFilter
):
"""
Custom filter for the GET list that filters all dashboards that a user has favored
"""
@ -57,7 +57,7 @@ class DashboardFavoriteFilter(BaseFavoriteFilter):
model = Dashboard
class DashboardAccessFilter(BaseFilter):
class DashboardAccessFilter(BaseFilter): # pylint: disable=too-few-public-methods
"""
List dashboards with the following criteria:
1. Those which the user owns
@ -140,7 +140,7 @@ class DashboardAccessFilter(BaseFilter):
return query
class FilterRelatedRoles(BaseFilter):
class FilterRelatedRoles(BaseFilter): # pylint: disable=too-few-public-methods
"""
A filter to allow searching for related roles of a resource.

View File

@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-many-lines,unused-argument
# pylint: disable=too-many-lines
import json
import logging
import re
@ -328,7 +328,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return new_exception(str(exception))
@classmethod
def get_allow_cost_estimate(cls, extra: Dict[str, Any]) -> bool:
def get_allow_cost_estimate( # pylint: disable=unused-argument
cls, extra: Dict[str, Any],
) -> bool:
return False
@classmethod
@ -581,8 +583,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return indexes
@classmethod
def extra_table_metadata(
cls, database: "Database", table_name: str, schema_name: str
def extra_table_metadata( # pylint: disable=unused-argument
cls, database: "Database", table_name: str, schema_name: str,
) -> Dict[str, Any]:
"""
Returns engine-specific table metadata
@ -683,7 +685,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
df.to_sql(con=engine, **to_sql_kwargs)
@classmethod
def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
def convert_dttm( # pylint: disable=unused-argument
cls, target_type: str, dttm: datetime,
) -> Optional[str]:
"""
Convert Python datetime object to a SQL expression
@ -815,8 +819,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return sorted(inspector.get_schema_names())
@classmethod
def get_table_names(
cls, database: "Database", inspector: Inspector, schema: Optional[str]
def get_table_names( # pylint: disable=unused-argument
cls, database: "Database", inspector: Inspector, schema: Optional[str],
) -> List[str]:
"""
Get all tables from schema
@ -831,8 +835,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return sorted(tables)
@classmethod
def get_view_names(
cls, database: "Database", inspector: Inspector, schema: Optional[str]
def get_view_names( # pylint: disable=unused-argument
cls, database: "Database", inspector: Inspector, schema: Optional[str],
) -> List[str]:
"""
Get all views from schema
@ -885,7 +889,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return inspector.get_columns(table_name, schema)
@classmethod
def where_latest_partition( # pylint: disable=too-many-arguments
def where_latest_partition( # pylint: disable=too-many-arguments,unused-argument
cls,
table_name: str,
schema: Optional[str],
@ -1072,7 +1076,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
"""
@classmethod
def execute(cls, cursor: Any, query: str, **kwargs: Any) -> None:
def execute( # pylint: disable=unused-argument
cls, cursor: Any, query: str, **kwargs: Any,
) -> None:
"""
Execute a SQL query
@ -1201,7 +1207,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return sqla_column_type.compile(dialect=dialect).upper()
@classmethod
def get_function_names(cls, database: "Database") -> List[str]:
def get_function_names( # pylint: disable=unused-argument
cls, database: "Database",
) -> List[str]:
"""
Get a list of function names that are able to be called on the database.
Used for SQL Lab autocomplete.
@ -1224,7 +1232,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return data
@staticmethod
def mutate_db_for_connection_test(database: "Database") -> None:
def mutate_db_for_connection_test( # pylint: disable=unused-argument
database: "Database",
) -> None:
"""
Some databases require passing additional parameters for validating database
connections. This method makes it possible to mutate the database instance prior
@ -1271,7 +1281,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
@classmethod
@memoized
def get_column_spec(
def get_column_spec( # pylint: disable=unused-argument
cls,
native_type: Optional[str],
source: utils.ColumnTypeSource = utils.ColumnTypeSource.GET_TABLE,
@ -1320,7 +1330,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return False
@classmethod
def get_cancel_query_id(cls, cursor: Any, query: Query) -> Optional[str]:
def get_cancel_query_id( # pylint: disable=unused-argument
cls, cursor: Any, query: Query,
) -> Optional[str]:
"""
Select identifiers from the database engine that uniquely identifies the
queries to cancel. The identifier is typically a session id, process id
@ -1334,7 +1346,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return None
@classmethod
def cancel_query(cls, cursor: Any, query: Query, cancel_query_id: str) -> bool:
def cancel_query( # pylint: disable=unused-argument
cls, cursor: Any, query: Query, cancel_query_id: str,
) -> bool:
"""
Cancel query in the underlying database.
@ -1407,7 +1421,7 @@ class BasicParametersMixin:
encryption_parameters: Dict[str, str] = {}
@classmethod
def build_sqlalchemy_uri(
def build_sqlalchemy_uri( # pylint: disable=unused-argument
cls,
parameters: BasicParametersType,
encryted_extra: Optional[Dict[str, str]] = None,
@ -1432,7 +1446,7 @@ class BasicParametersMixin:
)
@classmethod
def get_parameters_from_uri(
def get_parameters_from_uri( # pylint: disable=unused-argument
cls, uri: str, encrypted_extra: Optional[Dict[str, Any]] = None
) -> BasicParametersType:
url = make_url(uri)

View File

@ -20,9 +20,8 @@ if TYPE_CHECKING:
from pyhive.hive import Cursor
from TCLIService.ttypes import TFetchOrientation
# pylint: disable=protected-access
# TODO: contribute back to pyhive.
def fetch_logs(
def fetch_logs( # pylint: disable=protected-access
self: "Cursor",
_max_rows: int = 1024,
orientation: Optional["TFetchOrientation"] = None,

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-many-statements
import json
from superset import db
@ -172,7 +171,7 @@ POSITION_JSON = """\
}"""
def load_deck_dash() -> None:
def load_deck_dash() -> None: # pylint: disable=too-many-statements
print("Loading deck.gl dashboard")
slices = []
table = get_table_connector_registry()

View File

@ -58,8 +58,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
# pylint: disable=R0904
class SupersetAppInitializer:
class SupersetAppInitializer: # pylint: disable=too-many-public-methods
def __init__(self, app: SupersetApp) -> None:
super().__init__()

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=line-too-long,unused-argument
"""A collection of ORM sqlalchemy models for Superset"""
import enum
import json
@ -244,7 +243,7 @@ class Database(
uri = make_url(self.sqlalchemy_uri_decrypted)
encrypted_extra = self.get_encrypted_extra()
try:
parameters = self.db_engine_spec.get_parameters_from_uri(uri, encrypted_extra=encrypted_extra) # type: ignore
parameters = self.db_engine_spec.get_parameters_from_uri(uri, encrypted_extra=encrypted_extra) # type: ignore # pylint: disable=line-too-long,useless-suppression
except Exception: # pylint: disable=broad-except
parameters = {}
@ -479,7 +478,7 @@ class Database(
key=lambda self, *args, **kwargs: f"db:{self.id}:schema:None:table_list",
cache=cache_manager.data_cache,
)
def get_all_table_names_in_database(
def get_all_table_names_in_database( # pylint: disable=unused-argument
self,
cache: bool = False,
cache_timeout: Optional[bool] = None,
@ -494,7 +493,7 @@ class Database(
key=lambda self, *args, **kwargs: f"db:{self.id}:schema:None:view_list",
cache=cache_manager.data_cache,
)
def get_all_view_names_in_database(
def get_all_view_names_in_database( # pylint: disable=unused-argument
self,
cache: bool = False,
cache_timeout: Optional[bool] = None,
@ -506,10 +505,10 @@ class Database(
return self.db_engine_spec.get_all_datasource_names(self, "view")
@cache_util.memoized_func(
key=lambda self, schema, *args, **kwargs: f"db:{self.id}:schema:{schema}:table_list",
key=lambda self, schema, *args, **kwargs: f"db:{self.id}:schema:{schema}:table_list", # pylint: disable=line-too-long,useless-suppression
cache=cache_manager.data_cache,
)
def get_all_table_names_in_schema(
def get_all_table_names_in_schema( # pylint: disable=unused-argument
self,
schema: str,
cache: bool = False,
@ -539,10 +538,10 @@ class Database(
return []
@cache_util.memoized_func(
key=lambda self, schema, *args, **kwargs: f"db:{self.id}:schema:{schema}:view_list",
key=lambda self, schema, *args, **kwargs: f"db:{self.id}:schema:{schema}:view_list", # pylint: disable=line-too-long,useless-suppression
cache=cache_manager.data_cache,
)
def get_all_view_names_in_schema(
def get_all_view_names_in_schema( # pylint: disable=unused-argument
self,
schema: str,
cache: bool = False,
@ -573,7 +572,7 @@ class Database(
key=lambda self, *args, **kwargs: f"db:{self.id}:schema_list",
cache=cache_manager.data_cache,
)
def get_all_schema_names(
def get_all_schema_names( # pylint: disable=unused-argument
self,
cache: bool = False,
cache_timeout: Optional[int] = None,

View File

@ -74,7 +74,7 @@ class Slice( # pylint: disable=too-many-public-methods
# the last time a user has saved the chart, changed_on is referencing
# when the database row was last written
last_saved_at = Column(DateTime, nullable=True)
last_saved_by_fk = Column(Integer, ForeignKey("ab_user.id"), nullable=True,)
last_saved_by_fk = Column(Integer, ForeignKey("ab_user.id"), nullable=True)
last_saved_by = relationship(
security_manager.user_model, foreign_keys=[last_saved_by_fk]
)

View File

@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-few-public-methods,too-many-lines
# pylint: disable=too-many-lines
"""A set of constants and methods to manage permissions and security"""
import logging
import re
@ -78,7 +78,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
class SupersetSecurityListWidget(ListWidget):
class SupersetSecurityListWidget(ListWidget): # pylint: disable=too-few-public-methods
"""
Redeclaring to avoid circular imports
"""
@ -86,7 +86,7 @@ class SupersetSecurityListWidget(ListWidget):
template = "superset/fab_overrides/list.html"
class SupersetRoleListWidget(ListWidget):
class SupersetRoleListWidget(ListWidget): # pylint: disable=too-few-public-methods
"""
Role model view from FAB already uses a custom list widget override
So we override the override

View File

@ -30,7 +30,6 @@ from celery import Task
from celery.exceptions import SoftTimeLimitExceeded
from flask_babel import gettext as __
from sqlalchemy.orm import Session
from werkzeug.local import LocalProxy
from superset import app, results_backend, results_backend_use_msgpack, security_manager
from superset.dataframe import df_to_records
@ -38,7 +37,6 @@ from superset.db_engine_specs import BaseEngineSpec
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import SupersetErrorException, SupersetErrorsException
from superset.extensions import celery_app
from superset.models.core import Database
from superset.models.sql_lab import LimitingFactor, Query
from superset.result_set import SupersetResultSet
from superset.sql_parse import CtasMethod, ParsedQuery
@ -52,25 +50,13 @@ from superset.utils.core import (
from superset.utils.dates import now_as_float
from superset.utils.decorators import stats_timing
# pylint: disable=unused-argument, redefined-outer-name
def dummy_sql_query_mutator(
sql: str,
user_name: Optional[str],
security_manager: LocalProxy,
database: Database,
) -> str:
"""A no-op version of SQL_QUERY_MUTATOR"""
return sql
config = app.config
stats_logger = config["STATS_LOGGER"]
SQLLAB_TIMEOUT = config["SQLLAB_ASYNC_TIME_LIMIT_SEC"]
SQLLAB_HARD_TIMEOUT = SQLLAB_TIMEOUT + 60
SQL_MAX_ROW = config["SQL_MAX_ROW"]
SQLLAB_CTAS_NO_LIMIT = config["SQLLAB_CTAS_NO_LIMIT"]
SQL_QUERY_MUTATOR = config.get("SQL_QUERY_MUTATOR") or dummy_sql_query_mutator
SQL_QUERY_MUTATOR = config["SQL_QUERY_MUTATOR"]
log_query = config["QUERY_LOGGER"]
logger = logging.getLogger(__name__)
cancel_query_key = "cancel_query"
@ -192,8 +178,7 @@ def get_sql_results( # pylint: disable=too-many-arguments
return handle_query_error(ex, query, session)
# pylint: disable=too-many-arguments, too-many-locals, too-many-statements
def execute_sql_statement(
def execute_sql_statement( # pylint: disable=too-many-arguments,too-many-locals,too-many-statements
sql_statement: str,
query: Query,
user_name: Optional[str],

View File

@ -14,15 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-few-public-methods
from typing import Any, Dict, List, Optional
from superset.models.core import Database
class SQLValidationAnnotation:
class SQLValidationAnnotation: # pylint: disable=too-few-public-methods
"""Represents a single annotation (error/warning) in an SQL querytext"""
def __init__(
@ -47,7 +44,7 @@ class SQLValidationAnnotation:
}
class BaseSQLValidator:
class BaseSQLValidator: # pylint: disable=too-few-public-methods
"""BaseSQLValidator defines the interface for checking that a given sql
query is valid for a given database engine."""

View File

@ -124,7 +124,7 @@ class ExecuteSqlCommand(BaseCommand):
QueryStatus.TIMED_OUT,
]
def _run_sql_json_exec_from_scratch(self,) -> SqlJsonExecutionStatus:
def _run_sql_json_exec_from_scratch(self) -> SqlJsonExecutionStatus:
self.execution_context.set_database(self._get_the_query_db())
query = self.execution_context.create_query()
try:
@ -183,7 +183,7 @@ class ExecuteSqlCommand(BaseCommand):
self.session.commit()
raise SupersetErrorException(ex.error, status=403) from ex
def _render_query(self,) -> str:
def _render_query(self) -> str:
def validate(
rendered_query: str, template_processor: BaseTemplateProcessor
) -> None:
@ -232,7 +232,7 @@ class ExecuteSqlCommand(BaseCommand):
if self._is_required_to_set_limit():
self._set_query_limit(rendered_query)
def _is_required_to_set_limit(self,) -> bool:
def _is_required_to_set_limit(self) -> bool:
return not (
config.get("SQLLAB_CTAS_NO_LIMIT") and self.execution_context.select_as_cta
)
@ -382,10 +382,8 @@ class ExecuteSqlCommand(BaseCommand):
is_feature_enabled("SQLLAB_BACKEND_PERSISTENCE") and not query.select_as_cta
)
def _create_payload_from_execution_context(
# pylint: disable=invalid-name
self,
status: SqlJsonExecutionStatus,
def _create_payload_from_execution_context( # pylint: disable=invalid-name
self, status: SqlJsonExecutionStatus,
) -> str:
if status == SqlJsonExecutionStatus.HAS_RESULTS:

View File

@ -68,18 +68,17 @@ def load_chart_data_into_cache(
async_query_manager.update_job(
job_metadata, async_query_manager.STATUS_DONE, result_url=result_url,
)
except SoftTimeLimitExceeded as exc:
logger.warning("A timeout occurred while loading chart data, error: %s", exc)
raise exc
except Exception as exc:
except SoftTimeLimitExceeded as ex:
logger.warning("A timeout occurred while loading chart data, error: %s", ex)
raise ex
except Exception as ex:
# TODO: QueryContext should support SIP-40 style errors
# pylint: disable=no-member
error = exc.message if hasattr(exc, "message") else str(exc) # type: ignore
error = ex.message if hasattr(ex, "message") else str(ex) # type: ignore # pylint: disable=no-member
errors = [{"message": error}]
async_query_manager.update_job(
job_metadata, async_query_manager.STATUS_ERROR, errors=errors
)
raise exc
raise ex
@celery_app.task(name="load_explore_json_into_cache", soft_time_limit=query_timeout)
@ -127,16 +126,14 @@ def load_explore_json_into_cache( # pylint: disable=too-many-locals
except SoftTimeLimitExceeded as ex:
logger.warning("A timeout occurred while loading explore json, error: %s", ex)
raise ex
except Exception as exc:
# pylint: disable=no-member
if isinstance(exc, SupersetVizException):
# pylint: disable=no-member
errors = exc.errors
except Exception as ex:
if isinstance(ex, SupersetVizException):
errors = ex.errors # pylint: disable=no-member
else:
error = exc.message if hasattr(exc, "message") else str(exc) # type: ignore
error = ex.message if hasattr(ex, "message") else str(ex) # type: ignore # pylint: disable=no-member
errors = [error]
async_query_manager.update_job(
job_metadata, async_query_manager.STATUS_ERROR, errors=errors
)
raise exc
raise ex

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-few-public-methods
import json
import logging
from typing import Any, Dict, List, Optional, Union
@ -85,7 +83,7 @@ def get_url(chart: Slice, extra_filters: Optional[Dict[str, Any]] = None) -> str
return f"{baseurl}{chart.get_explore_url(overrides=extra_filters)}"
class Strategy:
class Strategy: # pylint: disable=too-few-public-methods
"""
A cache warm up strategy.
@ -115,7 +113,7 @@ class Strategy:
raise NotImplementedError("Subclasses must implement get_urls!")
class DummyStrategy(Strategy):
class DummyStrategy(Strategy): # pylint: disable=too-few-public-methods
"""
Warm up all charts.
@ -140,7 +138,7 @@ class DummyStrategy(Strategy):
return [get_url(chart) for chart in charts]
class TopNDashboardsStrategy(Strategy):
class TopNDashboardsStrategy(Strategy): # pylint: disable=too-few-public-methods
"""
Warm up charts in the top-n dashboards.
@ -187,7 +185,7 @@ class TopNDashboardsStrategy(Strategy):
return urls
class DashboardTagsStrategy(Strategy):
class DashboardTagsStrategy(Strategy): # pylint: disable=too-few-public-methods
"""
Warm up charts in dashboards with custom tags.

View File

@ -26,6 +26,7 @@ import urllib.request
from collections import namedtuple
from datetime import datetime, timedelta
from email.utils import make_msgid, parseaddr
from enum import Enum
from typing import (
Any,
Callable,
@ -72,8 +73,6 @@ from superset.utils.retries import retry_call
from superset.utils.screenshots import ChartScreenshot, WebDriverProxy
from superset.utils.urls import get_url_path
# pylint: disable=too-few-public-methods
if TYPE_CHECKING:
from flask_appbuilder.security.sqla.models import User
from werkzeug.datastructures import TypeConversionDict
@ -571,7 +570,7 @@ def schedule_alert_query(
raise RuntimeError("Unknown report type")
class AlertState:
class AlertState(str, Enum):
ERROR = "error"
TRIGGER = "trigger"
PASS = "pass"

View File

@ -138,8 +138,7 @@ def parse_past_timedelta(
)
# pylint: disable=too-many-arguments, too-many-locals, too-many-branches
def get_since_until(
def get_since_until( # pylint: disable=too-many-arguments,too-many-locals,too-many-branches
time_range: Optional[str] = None,
since: Optional[str] = None,
until: Optional[str] = None,

View File

@ -24,8 +24,7 @@ import flask.config
logger = logging.getLogger(__name__)
# pylint: disable=too-few-public-methods
class LoggingConfigurator(abc.ABC):
class LoggingConfigurator(abc.ABC): # pylint: disable=too-few-public-methods
@abc.abstractmethod
def configure_logging(
self, app_config: flask.config.Config, debug_mode: bool
@ -33,7 +32,9 @@ class LoggingConfigurator(abc.ABC):
pass
class DefaultLoggingConfigurator(LoggingConfigurator):
class DefaultLoggingConfigurator( # pylint: disable=too-few-public-methods
LoggingConfigurator
):
def configure_logging(
self, app_config: flask.config.Config, debug_mode: bool
) -> None:

View File

@ -67,8 +67,9 @@ MAXIMUM_DATE = date.today()
days_range = (MAXIMUM_DATE - MINIMUM_DATE).days
# pylint: disable=too-many-return-statements, too-many-branches
def get_type_generator(sqltype: sqlalchemy.sql.sqltypes) -> Callable[[], Any]:
def get_type_generator( # pylint: disable=too-many-return-statements,too-many-branches
sqltype: sqlalchemy.sql.sqltypes,
) -> Callable[[], Any]:
if isinstance(sqltype, sqlalchemy.dialects.mysql.types.TINYINT):
return lambda: random.choice([0, 1])

View File

@ -470,9 +470,8 @@ def diff(
return _append_columns(df, df_diff, columns)
# pylint: disable=too-many-arguments
@validate_column_args("source_columns", "compare_columns")
def compare(
def compare( # pylint: disable=too-many-arguments
df: DataFrame,
source_columns: List[str],
compare_columns: List[str],

View File

@ -376,8 +376,9 @@ def common_bootstrap_payload() -> Dict[str, Any]:
return bootstrap_data
# pylint: disable=invalid-name
def get_error_level_from_status_code(status: int) -> ErrorLevel:
def get_error_level_from_status_code( # pylint: disable=invalid-name
status: int,
) -> ErrorLevel:
if status < 400:
return ErrorLevel.INFO
if status < 500:

View File

@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=comparison-with-callable,line-too-long,too-many-lines
# pylint: disable=too-many-lines
from __future__ import annotations
import logging
@ -326,7 +326,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
requests = (
session.query(DAR)
.filter(
.filter( # pylint: disable=comparison-with-callable
DAR.datasource_id == datasource_id,
DAR.datasource_type == datasource_type,
DAR.created_by_fk == requested_by.id,
@ -1537,7 +1537,9 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
Dash = Dashboard
qry = (
db.session.query(Dash)
.filter(or_(Dash.created_by_fk == user_id, Dash.changed_by_fk == user_id))
.filter( # pylint: disable=comparison-with-callable
or_(Dash.created_by_fk == user_id, Dash.changed_by_fk == user_id)
)
.order_by(Dash.changed_on.desc())
)
payload = [
@ -1581,7 +1583,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
),
isouter=True,
)
.filter(
.filter( # pylint: disable=comparison-with-callable
or_(
Slice.id.in_(owner_ids_query),
Slice.created_by_fk == user_id,
@ -1617,7 +1619,9 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
user_id = g.user.get_id()
qry = (
db.session.query(Slice)
.filter(or_(Slice.created_by_fk == user_id, Slice.changed_by_fk == user_id))
.filter( # pylint: disable=comparison-with-callable
or_(Slice.created_by_fk == user_id, Slice.changed_by_fk == user_id)
)
.order_by(Slice.changed_on.desc())
)
payload = [
@ -1859,7 +1863,8 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
"""
Server side rendering for a dashboard
:param dashboard_id_or_slug: identifier for dashboard. used in the decorators
:param add_extra_log_payload: added by `log_this_with_manual_updates`, set a default value to appease pylint
:param add_extra_log_payload: added by `log_this_with_manual_updates`, set a
default value to appease pylint
:param dashboard: added by `check_dashboard_access`
"""
if not dashboard:
@ -2422,10 +2427,8 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
command_result: CommandResult = command.run()
return self._create_response_from_execution_context(command_result)
def _create_response_from_execution_context(
# pylint: disable=invalid-name, no-self-use
self,
command_result: CommandResult,
def _create_response_from_execution_context( # pylint: disable=invalid-name, no-self-use
self, command_result: CommandResult,
) -> FlaskResponse:
status_code = 200

View File

@ -23,10 +23,9 @@ from sqlalchemy.orm import Query
from superset import security_manager
# pylint: disable=too-few-public-methods
class FilterRelatedOwners(BaseFilter): # pylint: disable=too-few-public-methods
class FilterRelatedOwners(BaseFilter):
"""
A filter to allow searching for related owners of a resource.

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use, invalid-name
import json
from datetime import datetime
from unittest.mock import patch
@ -313,7 +311,7 @@ class TestChartsUpdateCommand(SupersetTestCase):
@patch("superset.security.manager.g")
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_update_v1_response(self, mock_sm_g, mock_g):
""""Test that a chart command updates properties"""
"""Test that a chart command updates properties"""
pk = db.session.query(Slice).all()[0].id
actor = security_manager.find_user(username="admin")
mock_g.user = mock_sm_g.user = actor
@ -334,7 +332,7 @@ class TestChartsUpdateCommand(SupersetTestCase):
@patch("superset.security.manager.g")
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_query_context_update_command(self, mock_sm_g, mock_g):
""""
""" "
Test that a user can generate the chart query context
payloadwithout affecting owners
"""

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use
from superset.commands.exceptions import CommandInvalidError
from superset.commands.importers.v1.utils import is_valid_config
from tests.integration_tests.base_tests import SupersetTestCase

View File

@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# isort:skip_file
# pylint: disable=too-many-public-methods, no-self-use, invalid-name, too-many-arguments
"""Unit tests for Superset"""
import json
from io import BytesIO

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use, invalid-name
import itertools
import json
from unittest.mock import MagicMock, patch

View File

@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# isort:skip_file
# pylint: disable=invalid-name, no-self-use, too-many-public-methods, too-many-arguments
"""Unit tests for Superset"""
import dataclasses
import json

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use, invalid-name
from unittest import mock, skip
from unittest.mock import patch

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=too-many-public-methods, invalid-name
"""Unit tests for Superset"""
import json
import unittest

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use, invalid-name, line-too-long
from operator import itemgetter
from typing import Any, List
from unittest.mock import patch

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=line-too-long
from typing import Any, Dict, List
# example V0 import/export format

View File

@ -14,10 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
class Row(object):
class Row:
def __init__(self, values):
self.values = values

View File

@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# isort:skip_file
# pylint: disable=too-many-public-methods, no-self-use, invalid-name, too-many-arguments
"""Unit tests for Superset"""
import json

View File

@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# isort:skip_file
# pylint: disable=invalid-name, no-self-use
"""Unit tests for Sql Lab"""
import unittest
from unittest.mock import MagicMock, patch

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use
import pytest
from superset.utils.core import form_data_to_adhoc, simple_filter_to_adhoc

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use
import io
import pandas as pd

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use
import datetime
import math
from typing import Any

View File

@ -14,19 +14,16 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=no-self-use
from typing import Any, Callable, Dict
import pytest
from superset.sql_lab import dummy_sql_query_mutator
from superset.utils.public_interfaces import compute_hash, get_warning_message
from tests.integration_tests.base_tests import SupersetTestCase
# These are public interfaces exposed by Superset. Make sure
# to only change the interfaces and update the hashes in new
# major versions of Superset.
hashes = {
dummy_sql_query_mutator: "Kv%NM3b;7BcpoD2wbPkW",
}
hashes: Dict[Callable[..., Any], str] = {}
@pytest.mark.parametrize("interface,expected_hash", list(hashes.items()))

View File

@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-argument, invalid-name
from flask.ctx import AppContext
from pytest_mock import MockFixture

View File

@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-argument, invalid-name
from datetime import datetime
from typing import List