Skip to content

Commit

Permalink
chore(pylint): Remove top-level disable (apache#16589)
Browse files Browse the repository at this point in the history
* chore(pylint): Remove top-level disable

* Update examples.py

* Update command.py

Co-authored-by: John Bodley <[email protected]>
  • Loading branch information
2 people authored and Emmanuel Bavoux committed Nov 14, 2021
1 parent ac0d8e3 commit 86d4fa2
Show file tree
Hide file tree
Showing 45 changed files with 682 additions and 656 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions RELEASING/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions superset/commands/importers/v1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,16 +76,16 @@ def run(self) -> None:

@classmethod
def _get_uuids(cls) -> Set[str]:
# pylint: disable=protected-access
return (
ImportDatabasesCommand._get_uuids()
| ImportDatasetsCommand._get_uuids()
| ImportChartsCommand._get_uuids()
| 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,
Expand Down
18 changes: 13 additions & 5 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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
Expand Down Expand Up @@ -178,9 +179,9 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
# 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

Expand Down Expand Up @@ -841,7 +842,7 @@ class CeleryConfig: # pylint: disable=too-few-public-methods
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],
Expand Down Expand Up @@ -986,7 +987,14 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC(
# 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
#
Expand Down
13 changes: 8 additions & 5 deletions superset/connectors/druid/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,7 +61,9 @@ def ensure_enabled(self) -> None:
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

Expand Down Expand Up @@ -149,7 +150,9 @@ def post_add(self, item: "DruidColumnInlineView") -> None:
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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -266,7 +269,7 @@ def _delete(self, pk: int) -> None:
DeleteMixin._delete(self, pk)


class DruidDatasourceModelView(
class DruidDatasourceModelView( # pylint: disable=too-many-ancestors
EnsureEnabledMixin, DatasourceModelView, DeleteMixin, YamlExportMixin,
):
datamodel = SQLAInterface(models.DruidDatasource)
Expand Down
12 changes: 6 additions & 6 deletions superset/dashboards/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +29,7 @@
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"

Expand All @@ -47,7 +45,9 @@ def apply(self, query: Query, value: Any) -> Query:
)


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
"""
Expand All @@ -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
Expand Down Expand Up @@ -140,7 +140,7 @@ def apply(self, query: Query, value: Any) -> Query:
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.
Expand Down
50 changes: 32 additions & 18 deletions superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -328,7 +328,9 @@ def get_dbapi_mapped_exception(cls, exception: Exception) -> Exception:
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
Expand Down Expand Up @@ -581,8 +583,8 @@ def normalize_indexes(cls, indexes: List[Dict[str, Any]]) -> List[Dict[str, Any]
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
Expand Down Expand Up @@ -683,7 +685,9 @@ def df_to_sql(
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
Expand Down Expand Up @@ -815,8 +819,8 @@ def get_schema_names(cls, inspector: Inspector) -> List[str]:
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
Expand All @@ -831,8 +835,8 @@ def get_table_names(
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
Expand Down Expand Up @@ -885,7 +889,7 @@ def get_columns(
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],
Expand Down Expand Up @@ -1072,7 +1076,9 @@ def update_impersonation_config(
"""

@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
Expand Down Expand Up @@ -1201,7 +1207,9 @@ def column_datatype_to_string(
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.
Expand All @@ -1224,7 +1232,9 @@ def pyodbc_rows_to_tuples(data: List[Any]) -> List[Tuple[Any, ...]]:
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
Expand Down Expand Up @@ -1271,7 +1281,7 @@ def is_select_query(cls, parsed_query: ParsedQuery) -> bool:

@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,
Expand Down Expand Up @@ -1320,7 +1330,9 @@ def has_implicit_cancel(cls) -> bool:
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
Expand All @@ -1334,7 +1346,9 @@ def get_cancel_query_id(cls, cursor: Any, query: Query) -> Optional[str]:
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.
Expand Down Expand Up @@ -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,
Expand All @@ -1432,7 +1446,7 @@ def build_sqlalchemy_uri(
)

@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)
Expand Down
3 changes: 1 addition & 2 deletions superset/db_engines/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
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,
Expand Down
3 changes: 1 addition & 2 deletions superset/examples/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -172,7 +171,7 @@
}"""


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()
Expand Down
3 changes: 1 addition & 2 deletions superset/initialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
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__()

Expand Down
Loading

0 comments on commit 86d4fa2

Please sign in to comment.