Skip to content

Commit f536f10

Browse files
Bump pylint from 2.17.5 to 3.0.2 in /misc/requirements (#733)
* Bump pylint from 2.17.5 to 3.0.2 in /misc/requirements Bumps [pylint](https://github.com/pylint-dev/pylint) from 2.17.5 to 3.0.2. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](pylint-dev/pylint@v2.17.5...v3.0.2) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Pylint checkers: remove __implements__ Was removed in pylint-dev/pylint#8404. * Pylint: Other fixes for pylint v3.0.0 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: karlch <[email protected]>
1 parent 1481386 commit f536f10

File tree

10 files changed

+21
-32
lines changed

10 files changed

+21
-32
lines changed

.pylintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ init-hook='import sys; sys.path.append("./scripts/pylint_checkers/")'
77
load-plugins=check_count,
88
check_docstring,
99
check_header,
10-
pylint.extensions.emptystring,
1110
pylint.extensions.check_elif,
1211
pylint.extensions.overlapping_exceptions,
1312

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pylint==2.17.5
1+
pylint==3.0.2
22
black==23.11.0
33
pydocstyle==6.3.0

scripts/pylint_checkers/check_count.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44

55
import astroid
66

7-
from pylint.interfaces import IAstroidChecker
87
from pylint.checkers import BaseChecker
98

109

1110
class CountComparedWithoutNone(BaseChecker):
1211
"""Checker to ensure count is compared to None."""
1312

14-
__implements__ = IAstroidChecker
15-
1613
name = "count-compared-directly"
1714

1815
# here we define our messages
@@ -43,8 +40,6 @@ def _check_compare_count(self, node):
4340
class CountAssignedToZero(BaseChecker):
4441
"""Checker to inform when default assigning count to zero."""
4542

46-
__implements__ = IAstroidChecker
47-
4843
name = "count-default-zero"
4944

5045
# here we define our messages
@@ -65,6 +60,8 @@ def visit_functiondef(self, node):
6560
In almost all cases None is what we want instead.
6661
"""
6762
for name, default in zip(node.args.args[::-1], node.args.defaults[::-1]):
63+
# We explicitly allow None, empty string, ...
64+
# pylint: disable=use-implicit-booleaness-not-comparison-to-zero
6865
if name.name == "count" and default.value == 0:
6966
self.add_message(self.name, node=node)
7067

scripts/pylint_checkers/check_docstring.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77

88
import astroid
99

10-
from pylint.interfaces import IAstroidChecker
1110
from pylint.checkers import BaseChecker
1211

1312

1413
class CommandMissingDocumentation(BaseChecker):
1514
"""Checker to ensure command docstrings include all information for docs."""
1615

17-
__implements__ = IAstroidChecker
18-
1916
name = "command-docstring"
2017

2118
name_ambiguous = "ambiguous-register"
@@ -68,9 +65,10 @@ def visit_functiondef(self, node):
6865
return
6966
argnames = {arg.name.replace("_", "-") for arg in node.args.args}
7067
regular_argnames = argnames - {"self", "count"}
71-
self._check_args_section(node, regular_argnames)
72-
self._check_count_section(node, argnames)
73-
self._check_syntax_section(node, regular_argnames)
68+
docstr = node.doc_node.value
69+
self._check_args_section(node, docstr, regular_argnames)
70+
self._check_count_section(node, docstr, argnames)
71+
self._check_syntax_section(node, docstr, regular_argnames)
7472

7573
@staticmethod
7674
def sections(docstr):
@@ -85,25 +83,25 @@ def sections(docstr):
8583
content += line
8684
return sections
8785

88-
def _check_syntax_section(self, node, argnames):
86+
def _check_syntax_section(self, node, docstr, argnames):
8987
"""Check if a syntax section is available for commands with arguments."""
9088
if not argnames:
9189
return
92-
for section in self.sections(node.doc):
90+
for section in self.sections(docstr):
9391
if re.match(r"\*\*syntax:\*\* ``.*``", section.strip()):
9492
return
9593
self.add_message(self.name_syntax, node=node, args=(node.name,))
9694

97-
def _check_count_section(self, node, argnames):
95+
def _check_count_section(self, node, docstr, argnames):
9896
"""Check if a count section is available for commands that support count."""
9997
if "count" not in argnames:
10098
return
101-
if "**count:**" not in node.doc:
99+
if "**count:**" not in docstr:
102100
self.add_message(self.name_count, node=node, args=(node.name,))
103101

104-
def _check_args_section(self, node, argnames):
102+
def _check_args_section(self, node, docstr, argnames):
105103
"""Check if all command arguments are documented."""
106-
docstring_argnames = self._get_args_from_docstring(node)
104+
docstring_argnames = self._get_args_from_docstring(node, docstr)
107105
difference = argnames - docstring_argnames
108106
for argname in difference:
109107
self.add_message(
@@ -145,7 +143,7 @@ def _is_command(self, node) -> bool:
145143
return True
146144
return False
147145

148-
def _get_args_from_docstring(self, node) -> Set[str]:
146+
def _get_args_from_docstring(self, node, docstr) -> Set[str]:
149147
"""Retrieve documented arguments from command docstring.
150148
151149
If an argument is not correctly formatted in the documentation section, the
@@ -154,11 +152,10 @@ def _get_args_from_docstring(self, node) -> Set[str]:
154152
Returns:
155153
Set of all documented argument names.
156154
"""
157-
docstr = node.doc
158155
if docstr is None:
159156
self.add_message(self.name_missing, node=node, args=(node.name,))
160157
return set()
161-
lines = [line.strip() for line in node.doc.split("\n")]
158+
lines = [line.strip() for line in docstr.split("\n")]
162159

163160
def _get_args(identifier, pattern):
164161
try:

scripts/pylint_checkers/check_header.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
"""Checker to ensure each python file includes a modeline and no copyright notice."""
44

5-
from pylint.interfaces import IRawChecker
65
from pylint.checkers import BaseChecker
76

87

98
class FileHeaderChecker(BaseChecker):
109
"""Checker to ensure each python file includes a modeline and copyright notice."""
1110

12-
__implements__ = IRawChecker
13-
1411
name = "file-header"
1512
name_modeline_missing = "modeline-missing"
1613
name_copyright_included = "copyright-included"

tests/unit/utils/test_thumbnail_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_do_not_create_thumbnail_for_thumbnail(qtbot, manager):
7474

7575
def check_thumbails_created(qtbot, manager, n_paths):
7676
def wait_thread():
77-
assert manager.pool.activeThreadCount() == 0
77+
assert not manager.pool.activeThreadCount()
7878

7979
qtbot.waitUntil(wait_thread, timeout=30000)
8080
assert len(os.listdir(manager.directory)) == n_paths

vimiv/commands/external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __call__(self, command: str, *args: str, pipe=False) -> None:
110110

111111
def _on_finished(self, exitcode, exitstatus):
112112
"""Check exit status and possibly process standard output on completion."""
113-
if exitstatus != QProcess.ExitStatus.NormalExit or exitcode != 0:
113+
if exitstatus != QProcess.ExitStatus.NormalExit or exitcode:
114114
log.error(
115115
"Error running external process '%s':\n%s",
116116
self.program(),

vimiv/imutils/_file_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _load(self, path: str, keep_zoom: bool):
103103
# Gif
104104
elif reader.is_animation:
105105
movie = QMovie(path)
106-
if not movie.isValid() or movie.frameCount() == 0:
106+
if not movie.isValid() or not movie.frameCount():
107107
log.error("Error reading animation %s: invalid data", path)
108108
return
109109
api.signals.movie_loaded.emit(movie, keep_zoom)

vimiv/qt/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
QT_VERSION_STR = qVersion()
2020

2121
if qt.USE_PYQT: # Signal aliases
22+
# pylint: disable=used-before-assignment
2223
BoundSignal = pyqtBoundSignal
2324
Signal = pyqtSignal
2425
Slot = pyqtSlot
@@ -27,6 +28,7 @@
2728
class Align:
2829
"""Namespace for easier access to the Qt alignment flags."""
2930

31+
# pylint: disable=used-before-assignment
3032
Center = Qt.AlignmentFlag.AlignCenter
3133
Left = Qt.AlignmentFlag.AlignLeft
3234
Right = Qt.AlignmentFlag.AlignRight

vimiv/utils/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,7 @@ def run_qprocess(cmd: str, *args: str, cwd=None) -> str:
423423
process.start(cmd, args)
424424
if not process.waitForFinished():
425425
raise OSError("Error waiting for process")
426-
if (
427-
process.exitStatus() != QProcess.ExitStatus.NormalExit
428-
or process.exitCode() != 0
429-
):
426+
if process.exitStatus() != QProcess.ExitStatus.NormalExit or process.exitCode():
430427
stderr = qbytearray_to_str(process.readAllStandardError()).strip()
431428
raise OSError(stderr)
432429
return qbytearray_to_str(process.readAllStandardOutput()).strip()

0 commit comments

Comments
 (0)