Skip to content

Commit d58a7c0

Browse files
Fix typo in pylintrc for useless-suppression (#5303)
* Fix typo in pylintrc for useless-suppression * Fix CI for information messages * Remove useless disables * Update CI and docs for 3.8+ Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent 2c68713 commit d58a7c0

32 files changed

+31
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
CACHE_VERSION: 3
12-
DEFAULT_PYTHON: 3.6
12+
DEFAULT_PYTHON: 3.8
1313
PRE_COMMIT_CACHE: ~/.cache/pre-commit
1414

1515
jobs:

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ repos:
5757
"-rn",
5858
"-sn",
5959
"--rcfile=pylintrc",
60+
"--fail-on=I",
6061
"--load-plugins=pylint.extensions.docparams",
6162
]
6263
# disabled plugins: pylint.extensions.mccabe

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ Release date: TBA
275275
Closes #3507
276276
Closes #5087
277277

278+
* It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
279+
allows using the latest ``ast`` parser.
280+
281+
* All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
282+
support python 3.6 and 3.7 and run tests for those interpreters.
283+
278284
* ``TypingChecker``
279285

280286
* Fix false-negative for ``deprecated-typing-alias`` and ``consider-using-alias``

doc/development_guide/contribute.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ You can clone Pylint and its dependencies from ::
6464
.. _git: https://git-scm.com/
6565

6666
Got a change for Pylint? Below are a few steps you should take to make sure
67-
your patch gets accepted.
67+
your patch gets accepted. We recommend using Python 3.8 or higher for development
68+
of Pylint as it gives you access to the latest ``ast`` parser.
6869

6970
- Test your code
7071

doc/whatsnew/2.12.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ Other Changes
195195
* Added the ``--enable-all-extensions`` command line option. It will load all available extensions
196196
which can be listed by running ``--list-extensions``
197197

198+
* It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
199+
allows using the latest ``ast`` parser.
200+
201+
* All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
202+
support python 3.6 and 3.7 and run tests for those interpreters.
203+
198204
* Fix crash on ``open()`` calls when the ``mode`` argument is not a simple string.
199205

200206
Partially closes #5321

pylint/checkers/exceptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ def visit_const(self, node: nodes.Const) -> None:
232232
)
233233

234234
def visit_instance(self, instance: objects.ExceptionInstance) -> None:
235-
# pylint: disable=protected-access
236235
cls = instance._proxied
237236
self.visit_classdef(cls)
238237

@@ -535,7 +534,6 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
535534
if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(
536535
exc
537536
):
538-
# pylint: disable=protected-access
539537
exc = exc._proxied
540538

541539
self._check_catching_non_exception(handler, exc, part)

pylint/checkers/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"""
5353

5454
import tokenize
55-
from functools import reduce # pylint: disable=redefined-builtin
55+
from functools import reduce
5656
from typing import List
5757

5858
from astroid import nodes

pylint/checkers/similar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2727
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
2828

29-
# pylint: disable=redefined-builtin
3029
"""a similarities / code duplication command line tool and pylint checker
3130
3231
The algorithm is based on comparing the hash value of n successive lines of a file.

pylint/checkers/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,6 @@ def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
13381338
continue
13391339

13401340
if isinstance(func_def, nodes.FunctionDef):
1341-
# pylint: disable=redundant-keyword-arg; some flow inference goes wrong here
13421341
return decorated_with(func_def, singledispatch_qnames)
13431342

13441343
return False

pylint/checkers/variables.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,6 @@ def _loopvar_name(self, node: astroid.Name) -> None:
17831783
self.add_message("undefined-loop-variable", args=node.name, node=node)
17841784

17851785
def _check_is_unused(self, name, node, stmt, global_names, nonlocal_names):
1786-
# pylint: disable=too-many-branches
17871786
# Ignore some special names specified by user configuration.
17881787
if self._is_name_ignored(stmt, name):
17891788
return

pylint/config/option.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def _check_choice(self):
181181
f"must not supply choices for type {self.type!r}", self
182182
)
183183

184-
# pylint: disable=unsupported-assignment-operation
185184
optparse.Option.CHECK_METHODS[2] = _check_choice # type: ignore[index]
186185

187186
def process(self, opt, value, values, parser):

pylint/extensions/overlapping_exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
4949
if exc is astroid.Uninferable:
5050
continue
5151
if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(exc):
52-
# pylint: disable=protected-access
5352
exc = exc._proxied
5453

5554
if not isinstance(exc, astroid.ClassDef):

pylint/lint/pylinter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,6 @@ def _load_reporters(self) -> None:
623623
sub_reporters.append(reporter)
624624
if reporter_output:
625625
(reporter_output,) = reporter_output
626-
# pylint: disable=consider-using-with
627626
output_file = stack.enter_context(
628627
open(reporter_output, "w", encoding="utf-8")
629628
)
@@ -1066,7 +1065,7 @@ def _check_file(self, get_ast, check_astroid_module, file: FileItem):
10661065
self.file_state = FileState(file.modpath)
10671066
# fix the current file (if the source file was not available or
10681067
# if it's actually a c extension)
1069-
self.current_file = ast_node.file # pylint: disable=maybe-no-member
1068+
self.current_file = ast_node.file
10701069
check_astroid_module(ast_node)
10711070
# warn about spurious inline messages handling
10721071
spurious_messages = self.file_state.iter_spurious_suppression_messages(
@@ -1312,6 +1311,7 @@ def _report_evaluation(self):
13121311
"refactor": self.stats.refactor,
13131312
"convention": self.stats.convention,
13141313
"statement": self.stats.statement,
1314+
"info": self.stats.info,
13151315
}
13161316
note = eval(evaluation, {}, stats_dict) # pylint: disable=eval-used
13171317
except Exception as ex: # pylint: disable=broad-except

pylint/lint/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def _cpu_count() -> int:
2222
"""Use sched_affinity if available for virtualized or containerized environments."""
2323
sched_getaffinity = getattr(os, "sched_getaffinity", None)
24-
# pylint: disable=not-callable,using-constant-test
24+
# pylint: disable=not-callable,using-constant-test,useless-suppression
2525
if sched_getaffinity:
2626
return len(sched_getaffinity(0))
2727
if multiprocessing:

pylint/reporters/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def __init__(
292292
ansi_terms = ["xterm-16color", "xterm-256color"]
293293
if os.environ.get("TERM") not in ansi_terms:
294294
if sys.platform == "win32":
295-
# pylint: disable=import-error,import-outside-toplevel
295+
# pylint: disable=import-outside-toplevel
296296
import colorama
297297

298298
self.out = colorama.AnsiToWin32(self.out)

pylint/testutils/lint_module_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,12 @@ def multiset_difference(
146146
unexpected[key] = -value
147147
return missing, unexpected
148148

149-
# pylint: disable=consider-using-with
150149
def _open_expected_file(self) -> TextIO:
151150
try:
152151
return open(self._test_file.expected_output, encoding="utf-8")
153152
except FileNotFoundError:
154153
return StringIO("")
155154

156-
# pylint: disable=consider-using-with
157155
def _open_source_file(self) -> TextIO:
158156
if self._test_file.base == "invalid_encoded_data":
159157
return open(self._test_file.source, encoding="utf-8")

pylint/testutils/reporter_for_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def finalize(self) -> str:
5050
self.reset()
5151
return result
5252

53-
# pylint: disable=unused-argument
5453
def on_set_current_module(self, module: str, filepath: Optional[str]) -> None:
5554
pass
5655

pylint/testutils/unittest_linter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class UnittestLinter:
1515
"""A fake linter class to capture checker messages."""
1616

17-
# pylint: disable=unused-argument, no-self-use
17+
# pylint: disable=unused-argument
1818

1919
def __init__(self):
2020
self._messages = []

pylint/utils/file_state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def _collect_block_lines(
7474
#
7575
# 1. def meth8(self):
7676
# 2. """test late disabling"""
77-
# 3. pylint: disable=not-callable
77+
# 3. pylint: disable=not-callable, useless-suppression
7878
# 4. print(self.blip)
79-
# 5. pylint: disable=no-member
79+
# 5. pylint: disable=no-member, useless-suppression
8080
# 6. print(self.bla)
8181
#
8282
# E1102 should be disabled from line 1 to 6 while E1101 from line 5 to 6

pylint/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def normalize_text(text, line_len=DEFAULT_LINE_LENGTH, indent=""):
9393

9494

9595
# py3k has no more cmp builtin
96-
def cmp(a, b): # pylint: disable=redefined-builtin
96+
def cmp(a, b):
9797
return (a > b) - (a < b)
9898

9999

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ confidence=
5757
# multiple time. See also the "--disable" option for examples.
5858
enable=
5959
use-symbolic-message-instead,
60-
useless-supression,
60+
useless-suppression,
6161
fixme
6262

6363
# Disable the message, report, category or checker with the given id(s). You

tests/benchmark/test_baseline_benchmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1010
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
1111

12-
# pylint: disable=protected-access,missing-function-docstring,no-self-use
12+
# pylint: disable=missing-function-docstring
1313

1414
import os
1515
import pprint

tests/checkers/unittest_design.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,4 @@ def test_ignore_paths_with_no_value(self) -> None:
5858
Compare against actual list to see if validator works."""
5959
options = get_global_option(self.checker, "exclude-too-few-public-methods")
6060

61-
# pylint: disable-next=use-implicit-booleaness-not-comparison
6261
assert options == []

tests/checkers/unittest_format.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,7 @@ def test_disable_global_option_end_of_line() -> None:
293293
Test for issue with disabling tokenizer messages
294294
that extend beyond the scope of the ast tokens
295295
"""
296-
file_ = tempfile.NamedTemporaryFile(
297-
"w", delete=False
298-
) # pylint: disable=consider-using-with
296+
file_ = tempfile.NamedTemporaryFile("w", delete=False)
299297
with file_:
300298
file_.write(
301299
"""

tests/config/unittest_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,4 @@ def test_ignore_paths_with_no_value(self) -> None:
9797
Compare against actual list to see if validator works."""
9898
options = get_global_option(self.checker, "ignore-paths")
9999

100-
# pylint: disable-next=use-implicit-booleaness-not-comparison
101100
assert options == []

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# pylint: disable=redefined-outer-name
2-
# pylint: disable=no-name-in-module
32
import os
43
from pathlib import Path
54

tests/lint/unittest_lint.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
from pylint.utils import FileState, print_full_documentation, tokenize_module
7171

7272
if os.name == "java":
73-
# pylint: disable=no-member
74-
# os._name is valid see https://www.programcreek.com/python/example/3842/os._name
7573
if os.name == "nt":
7674
HOME = "USERPROFILE"
7775
else:
@@ -799,7 +797,6 @@ def test_error_unexpected_value() -> None:
799797

800798

801799
class _CustomPyLinter(PyLinter):
802-
# pylint: disable=too-many-ancestors
803800
@staticmethod
804801
def should_analyze_file(modname: str, path: str, is_argument: bool = False) -> bool:
805802
if os.path.basename(path) == "wrong.py":

tests/profile/test_profile_against_externals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
88
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
99

10-
# pylint: disable=protected-access,missing-function-docstring,no-self-use
10+
# pylint: disable=missing-function-docstring
1111

1212
import os
1313
import pprint

tests/pyreverse/test_diagrams.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
55

66
"""Unit test for the diagrams modules"""
7-
# pylint: disable=redefined-outer-name
87
from typing import Callable
98

109
from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler

tests/regrtest_data/unused_variable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=missing-docstring
1+
# pylint: disable=missing-module-docstring, missing-function-docstring
22

33
def test():
44
variable = ''

tests/test_func.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class LintTestUsingModule:
5555
def _test_functionality(self) -> None:
5656
if self.module:
5757
tocheck = [self.package + "." + self.module]
58-
# pylint: disable=not-an-iterable; can't handle boolean checks for now
5958
if self.depends:
6059
tocheck += [
6160
self.package + f".{name.replace('.py', '')}" for name, _ in self.depends

tests/unittest_reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_template_option(linter):
5858

5959

6060
def test_deprecation_set_output(recwarn):
61-
"""TODO remove in 3.0""" # pylint: disable=fixme
61+
"""TODO remove in 3.0"""
6262
reporter = BaseReporter()
6363
# noinspection PyDeprecation
6464
reporter.set_output(sys.stdout)

0 commit comments

Comments
 (0)