Skip to content

Fix typo in pylintrc for useless-suppression #5303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
CACHE_VERSION: 3
DEFAULT_PYTHON: 3.6
DEFAULT_PYTHON: 3.8
PRE_COMMIT_CACHE: ~/.cache/pre-commit

jobs:
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ repos:
"-rn",
"-sn",
"--rcfile=pylintrc",
"--fail-on=I",
"--load-plugins=pylint.extensions.docparams",
]
# disabled plugins: pylint.extensions.mccabe
Expand Down
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ Release date: TBA
Closes #3507
Closes #5087

* It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
allows using the latest ``ast`` parser.

* All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
support python 3.6 and 3.7 and run tests for those interpreters.

* ``TypingChecker``

* Fix false-negative for ``deprecated-typing-alias`` and ``consider-using-alias``
Expand Down
3 changes: 2 additions & 1 deletion doc/development_guide/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ You can clone Pylint and its dependencies from ::
.. _git: https://git-scm.com/

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

- Test your code

Expand Down
6 changes: 6 additions & 0 deletions doc/whatsnew/2.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ Other Changes
* Added the ``--enable-all-extensions`` command line option. It will load all available extensions
which can be listed by running ``--list-extensions``

* It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
allows using the latest ``ast`` parser.

* All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
support python 3.6 and 3.7 and run tests for those interpreters.

* Fix crash on ``open()`` calls when the ``mode`` argument is not a simple string.

Partially closes #5321
2 changes: 0 additions & 2 deletions pylint/checkers/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def visit_const(self, node: nodes.Const) -> None:
)

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

Expand Down Expand Up @@ -535,7 +534,6 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(
exc
):
# pylint: disable=protected-access
exc = exc._proxied

self._check_catching_non_exception(handler, exc, part)
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"""

import tokenize
from functools import reduce # pylint: disable=redefined-builtin
from functools import reduce
from typing import List

from astroid import nodes
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE

# pylint: disable=redefined-builtin
"""a similarities / code duplication command line tool and pylint checker

The algorithm is based on comparing the hash value of n successive lines of a file.
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,6 @@ def is_registered_in_singledispatch_function(node: nodes.FunctionDef) -> bool:
continue

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

return False
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,6 @@ def _loopvar_name(self, node: astroid.Name) -> None:
self.add_message("undefined-loop-variable", args=node.name, node=node)

def _check_is_unused(self, name, node, stmt, global_names, nonlocal_names):
# pylint: disable=too-many-branches
# Ignore some special names specified by user configuration.
if self._is_name_ignored(stmt, name):
return
Expand Down
1 change: 0 additions & 1 deletion pylint/config/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def _check_choice(self):
f"must not supply choices for type {self.type!r}", self
)

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

def process(self, opt, value, values, parser):
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/overlapping_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
if exc is astroid.Uninferable:
continue
if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(exc):
# pylint: disable=protected-access
exc = exc._proxied

if not isinstance(exc, astroid.ClassDef):
Expand Down
4 changes: 2 additions & 2 deletions pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ def _load_reporters(self) -> None:
sub_reporters.append(reporter)
if reporter_output:
(reporter_output,) = reporter_output
# pylint: disable=consider-using-with
output_file = stack.enter_context(
open(reporter_output, "w", encoding="utf-8")
)
Expand Down Expand Up @@ -1066,7 +1065,7 @@ def _check_file(self, get_ast, check_astroid_module, file: FileItem):
self.file_state = FileState(file.modpath)
# fix the current file (if the source file was not available or
# if it's actually a c extension)
self.current_file = ast_node.file # pylint: disable=maybe-no-member
self.current_file = ast_node.file
check_astroid_module(ast_node)
# warn about spurious inline messages handling
spurious_messages = self.file_state.iter_spurious_suppression_messages(
Expand Down Expand Up @@ -1312,6 +1311,7 @@ def _report_evaluation(self):
"refactor": self.stats.refactor,
"convention": self.stats.convention,
"statement": self.stats.statement,
"info": self.stats.info,
}
note = eval(evaluation, {}, stats_dict) # pylint: disable=eval-used
except Exception as ex: # pylint: disable=broad-except
Expand Down
2 changes: 1 addition & 1 deletion pylint/lint/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
def _cpu_count() -> int:
"""Use sched_affinity if available for virtualized or containerized environments."""
sched_getaffinity = getattr(os, "sched_getaffinity", None)
# pylint: disable=not-callable,using-constant-test
# pylint: disable=not-callable,using-constant-test,useless-suppression
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unsolvable atm. The pre-commit env does have sched_getaffinity so this will always create some sort of error.

if sched_getaffinity:
return len(sched_getaffinity(0))
if multiprocessing:
Expand Down
2 changes: 1 addition & 1 deletion pylint/reporters/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def __init__(
ansi_terms = ["xterm-16color", "xterm-256color"]
if os.environ.get("TERM") not in ansi_terms:
if sys.platform == "win32":
# pylint: disable=import-error,import-outside-toplevel
# pylint: disable=import-outside-toplevel
import colorama

self.out = colorama.AnsiToWin32(self.out)
Expand Down
2 changes: 0 additions & 2 deletions pylint/testutils/lint_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,12 @@ def multiset_difference(
unexpected[key] = -value
return missing, unexpected

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

# pylint: disable=consider-using-with
def _open_source_file(self) -> TextIO:
if self._test_file.base == "invalid_encoded_data":
return open(self._test_file.source, encoding="utf-8")
Expand Down
1 change: 0 additions & 1 deletion pylint/testutils/reporter_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def finalize(self) -> str:
self.reset()
return result

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

Expand Down
2 changes: 1 addition & 1 deletion pylint/testutils/unittest_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class UnittestLinter:
"""A fake linter class to capture checker messages."""

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

def __init__(self):
self._messages = []
Expand Down
4 changes: 2 additions & 2 deletions pylint/utils/file_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def _collect_block_lines(
#
# 1. def meth8(self):
# 2. """test late disabling"""
# 3. pylint: disable=not-callable
# 3. pylint: disable=not-callable, useless-suppression
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the most elegant way to allow us to still fail on I.

# 4. print(self.blip)
# 5. pylint: disable=no-member
# 5. pylint: disable=no-member, useless-suppression
# 6. print(self.bla)
#
# E1102 should be disabled from line 1 to 6 while E1101 from line 5 to 6
Expand Down
2 changes: 1 addition & 1 deletion pylint/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def normalize_text(text, line_len=DEFAULT_LINE_LENGTH, indent=""):


# py3k has no more cmp builtin
def cmp(a, b): # pylint: disable=redefined-builtin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was useless since pylint 2.0 πŸ˜„

def cmp(a, b):
return (a > b) - (a < b)


Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ confidence=
# multiple time. See also the "--disable" option for examples.
enable=
use-symbolic-message-instead,
useless-supression,
useless-suppression,
fixme

# Disable the message, report, category or checker with the given id(s). You
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmark/test_baseline_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE

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

import os
import pprint
Expand Down
1 change: 0 additions & 1 deletion tests/checkers/unittest_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ def test_ignore_paths_with_no_value(self) -> None:
Compare against actual list to see if validator works."""
options = get_global_option(self.checker, "exclude-too-few-public-methods")

# pylint: disable-next=use-implicit-booleaness-not-comparison
assert options == []
4 changes: 1 addition & 3 deletions tests/checkers/unittest_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ def test_disable_global_option_end_of_line() -> None:
Test for issue with disabling tokenizer messages
that extend beyond the scope of the ast tokens
"""
file_ = tempfile.NamedTemporaryFile(
"w", delete=False
) # pylint: disable=consider-using-with
file_ = tempfile.NamedTemporaryFile("w", delete=False)
with file_:
file_.write(
"""
Expand Down
1 change: 0 additions & 1 deletion tests/config/unittest_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ def test_ignore_paths_with_no_value(self) -> None:
Compare against actual list to see if validator works."""
options = get_global_option(self.checker, "ignore-paths")

# pylint: disable-next=use-implicit-booleaness-not-comparison
assert options == []
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# pylint: disable=redefined-outer-name
# pylint: disable=no-name-in-module
import os
from pathlib import Path

Expand Down
3 changes: 0 additions & 3 deletions tests/lint/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
from pylint.utils import FileState, print_full_documentation, tokenize_module

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


class _CustomPyLinter(PyLinter):
# pylint: disable=too-many-ancestors
@staticmethod
def should_analyze_file(modname: str, path: str, is_argument: bool = False) -> bool:
if os.path.basename(path) == "wrong.py":
Expand Down
2 changes: 1 addition & 1 deletion tests/profile/test_profile_against_externals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE

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

import os
import pprint
Expand Down
1 change: 0 additions & 1 deletion tests/pyreverse/test_diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE

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

from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
Expand Down
2 changes: 1 addition & 1 deletion tests/regrtest_data/unused_variable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=missing-docstring
# pylint: disable=missing-module-docstring, missing-function-docstring

def test():
variable = ''
Expand Down
1 change: 0 additions & 1 deletion tests/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class LintTestUsingModule:
def _test_functionality(self) -> None:
if self.module:
tocheck = [self.package + "." + self.module]
# pylint: disable=not-an-iterable; can't handle boolean checks for now
if self.depends:
tocheck += [
self.package + f".{name.replace('.py', '')}" for name, _ in self.depends
Expand Down
2 changes: 1 addition & 1 deletion tests/unittest_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_template_option(linter):


def test_deprecation_set_output(recwarn):
"""TODO remove in 3.0""" # pylint: disable=fixme
"""TODO remove in 3.0"""
reporter = BaseReporter()
# noinspection PyDeprecation
reporter.set_output(sys.stdout)
Expand Down