Skip to content

Commit

Permalink
chore: Update pylint to 2.17.4 (apache#24700)
Browse files Browse the repository at this point in the history
Co-authored-by: John Bodley <[email protected]>
  • Loading branch information
EugeneTorap and john-bodley authored Jul 25, 2023
1 parent 59ef066 commit 67fbb2d
Show file tree
Hide file tree
Showing 99 changed files with 297 additions and 336 deletions.
57 changes: 3 additions & 54 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ unsafe-load-any-extension=no
# run arbitrary code
extension-pkg-whitelist=pyarrow

# Allow optimization of some AST trees. This will activate a peephole AST
# optimizer, which will apply various small optimizations. For instance, it can
# be used to obtain the result of joining multiple strings with the addition
# operator. Joining a lot of strings can lead to a maximum recursion error in
# Pylint and this flag can prevent that. It has one side effect, the resulting
# AST will be different than the one from reality. This option is deprecated
# and it will be removed in Pylint 2.0.
optimize-ast=no


[MESSAGES CONTROL]

Expand All @@ -83,11 +74,11 @@ enable=
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=
cyclic-import, # re-enable once this no longer raises false positives
missing-docstring,
duplicate-code,
unspecified-encoding,
# re-enable once this no longer raises false positives
too-many-instance-attributes
too-many-instance-attributes # re-enable once this no longer raises false positives

[REPORTS]

Expand All @@ -96,12 +87,6 @@ disable=
# mypackage.mymodule.MyReporterClass.
output-format=text

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]". This option is deprecated
# and it will be removed in Pylint 2.0.
files-output=no

# Tells whether to display a full report or only the messages
reports=yes

Expand Down Expand Up @@ -141,63 +126,33 @@ property-classes=
# Regular expression matching correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for argument names
argument-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct method names
method-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for method names
method-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct variable names
variable-rgx=[a-z_][a-z0-9_]{1,30}$

# Naming hint for variable names
variable-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$

# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$

# Regular expression matching correct constant names
const-rgx=(([A-Za-z_][A-Za-z0-9_]*)|(__.*__))$

# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Regular expression matching correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$

# Naming hint for class names
class-name-hint=[A-Z_][a-zA-Z0-9]+$

# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Regular expression matching correct attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for attribute names
attr-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression matching correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$

# Naming hint for function names
function-name-hint=[a-z_][a-z0-9_]{2,30}$

# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
Expand Down Expand Up @@ -225,12 +180,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# else.
single-line-if-stmt=no

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator

# Maximum number of lines in a module
max-module-lines=1000

Expand Down Expand Up @@ -427,4 +376,4 @@ analyse-fallback-blocks=no

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ werkzeug==2.3.3
# flask
# flask-jwt-extended
# flask-login
wrapt==1.12.1
wrapt==1.15.0
# via deprecated
wtforms==2.3.3
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/development.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ipython
progress>=1.5,<2
pyinstrument>=4.0.2,<5
pylint==2.9.6
pylint
python-ldap>=3.4.3
setuptools>=65.5.1
sqloxide
18 changes: 13 additions & 5 deletions requirements/development.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:4c0ce3a84b01a5a3fe6c72cbf2fc96e5eada2dbe
# SHA1:e35d6e709dc86002ca35ad59f7119aa6cc1e7179
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -10,7 +10,9 @@
# via
# -r requirements/base.in
# -r requirements/development.in
astroid==2.6.6
appnope==0.1.3
# via ipython
astroid==2.15.6
# via pylint
asttokens==2.2.1
# via stack-data
Expand All @@ -32,6 +34,8 @@ charset-normalizer==3.1.0
# via requests
decorator==5.1.1
# via ipython
dill==0.3.6
# via pylint
et-xmlfile==1.1.0
# via openpyxl
executing==1.2.0
Expand Down Expand Up @@ -60,7 +64,7 @@ linear-tsv==1.1.0
# via tabulator
matplotlib-inline==0.1.6
# via ipython
mccabe==0.6.1
mccabe==0.7.0
# via pylint
mysqlclient==2.1.0
# via apache-superset
Expand All @@ -74,6 +78,8 @@ pickleshare==0.7.5
# via ipython
pillow==9.5.0
# via apache-superset
platformdirs==3.8.1
# via pylint
progress==1.6
# via -r requirements/development.in
psycopg2-binary==2.9.6
Expand All @@ -96,7 +102,7 @@ pyhive[hive]==0.6.5
# via apache-superset
pyinstrument==4.4.0
# via -r requirements/development.in
pylint==2.9.6
pylint==2.17.4
# via -r requirements/development.in
python-ldap==3.4.3
# via -r requirements/development.in
Expand Down Expand Up @@ -126,7 +132,9 @@ thrift==0.16.0
# thrift-sasl
thrift-sasl==0.4.3
# via pyhive
toml==0.10.2
tomli==2.0.1
# via pylint
tomlkit==0.11.8
# via pylint
traitlets==5.9.0
# via
Expand Down
2 changes: 1 addition & 1 deletion superset/charts/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def validate(self) -> None:
if reports := ReportScheduleDAO.find_by_chart_ids(self._model_ids):
report_names = [report.name for report in reports]
raise ChartDeleteFailedReportsExistError(
_("There are associated alerts or reports: %s" % ",".join(report_names))
_(f"There are associated alerts or reports: {','.join(report_names)}")
)
# Check ownership
for model in self._models:
Expand Down
2 changes: 1 addition & 1 deletion superset/charts/commands/warm_up_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run(self) -> dict[str, Any]:
else get_dashboard_extra_filters(chart.id, self._dashboard_id)
)

g.form_data = form_data # pylint: disable=assigning-non-slot
g.form_data = form_data
payload = get_viz(
datasource_type=chart.datasource.type,
datasource_id=chart.datasource.id,
Expand Down
7 changes: 3 additions & 4 deletions superset/charts/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_data(self, pk: int) -> Response:
query_context = self._create_query_context_from_form(json_body)
command = ChartDataCommand(query_context)
command.validate()
except DatasourceNotFound as error:
except DatasourceNotFound:
return self.response_404()
except QueryObjectValidationError as error:
return self.response_400(message=error.message)
Expand Down Expand Up @@ -233,7 +233,7 @@ def data(self) -> Response:
query_context = self._create_query_context_from_form(json_body)
command = ChartDataCommand(query_context)
command.validate()
except DatasourceNotFound as error:
except DatasourceNotFound:
return self.response_404()
except QueryObjectValidationError as error:
return self.response_400(message=error.message)
Expand Down Expand Up @@ -420,11 +420,10 @@ def _get_data_response(

return self._send_chart_response(result, form_data, datasource)

# pylint: disable=invalid-name, no-self-use
# pylint: disable=invalid-name
def _load_query_context_form_from_cache(self, cache_key: str) -> dict[str, Any]:
return QueryContextCacheLoader.load(cache_key)

# pylint: disable=no-self-use
def _create_query_context_from_form(
self, form_data: dict[str, Any]
) -> QueryContext:
Expand Down
3 changes: 2 additions & 1 deletion superset/charts/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def apply(self, query: Query, value: Any) -> Query:
Slice.id == FavStar.obj_id,
),
isouter=True,
).filter( # pylint: disable=comparison-with-callable
).filter(
# pylint: disable=comparison-with-callable
or_(
Slice.id.in_(owner_ids_query),
Slice.created_by_fk == get_user_id(),
Expand Down
4 changes: 3 additions & 1 deletion superset/charts/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ def apply_post_process(

for query in result["queries"]:
if query["result_format"] not in (rf.value for rf in ChartDataResultFormat):
raise Exception(f"Result format {query['result_format']} not supported")
raise Exception( # pylint: disable=broad-exception-raised
f"Result format {query['result_format']} not supported"
)

data = query["data"]

Expand Down
4 changes: 0 additions & 4 deletions superset/cli/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def export_dashboards(dashboard_file: Optional[str] = None) -> None:
from superset.dashboards.commands.export import ExportDashboardsCommand
from superset.models.dashboard import Dashboard

# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username="admin")

dashboard_ids = [id_ for (id_,) in db.session.query(Dashboard.id).all()]
Expand Down Expand Up @@ -109,7 +108,6 @@ def export_datasources(datasource_file: Optional[str] = None) -> None:
from superset.connectors.sqla.models import SqlaTable
from superset.datasets.commands.export import ExportDatasetsCommand

# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username="admin")

dataset_ids = [id_ for (id_,) in db.session.query(SqlaTable.id).all()]
Expand Down Expand Up @@ -151,7 +149,6 @@ def import_dashboards(path: str, username: Optional[str]) -> None:
)

if username is not None:
# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username=username)
if is_zipfile(path):
with ZipFile(path) as bundle:
Expand Down Expand Up @@ -317,7 +314,6 @@ def import_dashboards(path: str, recursive: bool, username: str) -> None:
elif path_object.exists() and recursive:
files.extend(path_object.rglob("*.json"))
if username is not None:
# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username=username)
contents = {}
for path_ in files:
Expand Down
9 changes: 2 additions & 7 deletions superset/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def superset() -> None:

@app.shell_context_processor
def make_shell_context() -> dict[str, Any]:
return dict(app=app, db=db)
return {"app": app, "db": db}


# add sub-commands
Expand Down Expand Up @@ -71,12 +71,7 @@ def init() -> None:
def version(verbose: bool) -> None:
"""Prints the current version number"""
print(Fore.BLUE + "-=" * 15)
print(
Fore.YELLOW
+ "Superset "
+ Fore.CYAN
+ "{version}".format(version=app.config["VERSION_STRING"])
)
print(Fore.YELLOW + "Superset " + Fore.CYAN + f"{app.config['VERSION_STRING']}")
print(Fore.BLUE + "-=" * 15)
if verbose:
print("[DB] : " + f"{db.engine}")
Expand Down
2 changes: 1 addition & 1 deletion superset/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update_api_docs() -> None:
title=current_app.appbuilder.app_name,
version=api_version,
openapi_version="3.0.2",
info=dict(description=current_app.appbuilder.app_name),
info={"description": current_app.appbuilder.app_name},
plugins=[MarshmallowPlugin(schema_name_resolver=resolver)],
servers=[{"url": "http://localhost:8088"}],
)
Expand Down
2 changes: 1 addition & 1 deletion superset/commands/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
super().__init__(
_(
self.message_format.format(
object_type, '"%s" ' % object_id if object_id else ""
object_type, f'"{object_id}" ' if object_id else ""
)
),
exception,
Expand Down
6 changes: 4 additions & 2 deletions superset/commands/importers/v1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _get_uuids(cls) -> set[str]:
)

@staticmethod
def _import( # pylint: disable=arguments-differ, too-many-locals, too-many-branches
def _import( # pylint: disable=too-many-locals, too-many-branches
session: Session,
configs: dict[str, Any],
overwrite: bool = False,
Expand Down Expand Up @@ -120,7 +120,9 @@ def _import( # pylint: disable=arguments-differ, too-many-locals, too-many-bran
# find the ID of the corresponding database
if config["database_uuid"] not in database_ids:
if examples_db is None:
raise Exception("Cannot find examples database")
raise Exception( # pylint: disable=broad-exception-raised
"Cannot find examples database"
)
config["database_id"] = examples_db.id
else:
config["database_id"] = database_ids[config["database_uuid"]]
Expand Down
1 change: 0 additions & 1 deletion superset/common/query_context_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def create(
cache_values=cache_values,
)

# pylint: disable=no-self-use
def _convert_to_model(self, datasource: DatasourceDict) -> BaseDatasource:
return DatasourceDAO.get_datasource(
session=db.session,
Expand Down
2 changes: 1 addition & 1 deletion superset/common/query_context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def get_native_annotation_data(query_obj: QueryObject) -> dict[str, Any]:
def get_viz_annotation_data(
annotation_layer: dict[str, Any], force: bool
) -> dict[str, Any]:
# pylint: disable=import-outside-toplevel,superfluous-parens
# pylint: disable=import-outside-toplevel
from superset.charts.data.commands.get_data_command import ChartDataCommand

if not (chart := ChartDAO.find_by_id(annotation_layer["value"])):
Expand Down
2 changes: 1 addition & 1 deletion superset/common/query_object_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _convert_to_model(self, datasource: DatasourceDict) -> BaseDatasource:
session=self._session_maker(),
)

def _process_extras( # pylint: disable=no-self-use
def _process_extras(
self,
extras: dict[str, Any] | None,
) -> dict[str, Any]:
Expand Down
Loading

0 comments on commit 67fbb2d

Please sign in to comment.