From 262a2dac6c32f1d3f710e5242f728cda525f4a68 Mon Sep 17 00:00:00 2001 From: Jack McCluskey <34928439+jrmccluskey@users.noreply.github.com> Date: Thu, 31 Aug 2023 10:53:49 -0400 Subject: [PATCH] Upgrade pylint, re-enable bad-builtins check (#28239) * Re-enable bad-builtins check * Bump pylint version * New bounds on astroid compatible w/ new pylint * Add to disabled check list * More disables + start marking ones to re-enable later * Add issue links, remove an unused import --- .pre-commit-config.yaml | 2 +- sdks/python/.pylintrc | 23 +++++++++++++++++-- .../apache_beam/ml/inference/base_test.py | 1 - sdks/python/tox.ini | 4 ++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 72f7ec9642eb..a6c0faae0823 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: - repo: https://github.com/pycqa/pylint # this rev is a release tag in the repo above and corresponds with a pylint # version. make sure this matches the version of pylint in tox.ini. - rev: v2.11.1 + rev: v2.17.5 hooks: - id: pylint args: ["--rcfile=sdks/python/.pylintrc"] diff --git a/sdks/python/.pylintrc b/sdks/python/.pylintrc index 27ad7fc62862..38913a326a4a 100644 --- a/sdks/python/.pylintrc +++ b/sdks/python/.pylintrc @@ -18,6 +18,7 @@ [MASTER] # Ignore auto-generated files. ignore=clients +load-plugins=pylint.extensions.no_self_use,pylint.extensions.bad_builtin [BASIC] # Regular expression which should only match the name @@ -69,7 +70,6 @@ variable-rgx=^[a-z][a-z0-9_]*$ inlinevar-rgx=^[a-z][a-z0-9_]*$ # List of builtins function names that should not be used, separated by a comma -# TODO(https://github.com/apache/beam/issues/27473) Remove or re-enable bad-functions=input,apply,reduce # Good variable names which should always be accepted, separated by a comma @@ -85,11 +85,16 @@ disable = arguments-differ, arguments-renamed, attribute-defined-outside-init, - bad-builtin, # TODO(https://github.com/apache/beam/issues/27473) Remove or re-enable + bad-builtin, broad-except, + broad-exception-raised, + c-extension-no-member, comparison-with-callable, + consider-iterating-dictionary, + consider-using-dict-items, consider-using-enumerate, consider-using-f-string, + consider-using-generator, consider-using-in, consider-using-sys-exit, consider-using-with, @@ -97,6 +102,7 @@ disable = design, fixme, global-statement, + global-variable-undefined, import-error, import-outside-toplevel, import-self, @@ -108,7 +114,9 @@ disable = locally-disabled, logging-not-lazy, missing-docstring, + modified-iterating-list, multiple-statements, + missing-timeout, #TODO(https://github.com/apache/beam/issues/28240) Enable and fix warnings no-self-use, no-else-break, no-else-continue, @@ -126,23 +134,34 @@ disable = redefined-builtin, redefined-outer-name, redundant-keyword-arg, + self-cls-assignment, similarities, simplifiable-if-statement, stop-iteration-return, super-init-not-called, + superfluous-parens, + typevar-name-mismatch, #TODO(https://github.com/apache/beam/issues/28241) Enable and fix warnings try-except-raise, undefined-variable, unexpected-keyword-arg, unidiomatic-typecheck, unnecessary-comprehension, + unnecessary-direct-lambda-call, + unnecessary-dunder-call, unnecessary-lambda, + unnecessary-lambda-assignment, unnecessary-pass, unneeded-not, + use-implicit-booleaness-not-comparison, #TODO(https://github.com/apache/beam/issues/28244) Enable and fix warnings + used-before-assignment, unsubscriptable-object, + unsupported-binary-operation, unspecified-encoding, #TODO(https://github.com/apache/beam/issues/21236) Enable explicit encoding unused-argument, + use-dict-literal, unused-wildcard-import, useless-object-inheritance, + useless-with-lock, #TODO(https://github.com/apache/beam/issues/28242) Enable and fix warnings wildcard-import, wrong-import-order, diff --git a/sdks/python/apache_beam/ml/inference/base_test.py b/sdks/python/apache_beam/ml/inference/base_test.py index f2146cdd1e56..3180c697a36a 100644 --- a/sdks/python/apache_beam/ml/inference/base_test.py +++ b/sdks/python/apache_beam/ml/inference/base_test.py @@ -24,7 +24,6 @@ from typing import Any from typing import Dict from typing import Iterable -from typing import List from typing import Mapping from typing import Optional from typing import Sequence diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index 130b54c07fb9..1dc605595d55 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -125,9 +125,9 @@ setenv = # keep the version of pylint in sync with the 'rev' in .pre-commit-config.yaml deps = -r build-requirements.txt - astroid<2.9,>=2.8.0 + astroid<2.17.0,>=2.15.6 pycodestyle==2.8.0 - pylint==2.11.1 + pylint==2.17.5 isort==4.2.15 flake8==4.0.1 commands =