Skip to content

Commit 66f46bf

Browse files
[deprecation] 'Pylinter.check' now takes sequence of str only (#8463)
1 parent 5a72e22 commit 66f46bf

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

doc/whatsnew/fragments/8463.internal

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Following a deprecation period, ``Pylinter.check`` now only work with sequences of strings, not strings.
2+
3+
Refs #8463

pylint/lint/pylinter.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -637,23 +637,12 @@ def _discover_files(self, files_or_modules: Sequence[str]) -> Iterator[str]:
637637
else:
638638
yield something
639639

640-
def check(self, files_or_modules: Sequence[str] | str) -> None:
640+
def check(self, files_or_modules: Sequence[str]) -> None:
641641
"""Main checking entry: check a list of files or modules from their name.
642642
643643
files_or_modules is either a string or list of strings presenting modules to check.
644644
"""
645-
# 1) Initialize
646645
self.initialize()
647-
648-
# 2) Gather all files
649-
if not isinstance(files_or_modules, (list, tuple)):
650-
# TODO: 3.0: Remove deprecated typing and update docstring
651-
warnings.warn(
652-
"In pylint 3.0, the checkers check function will only accept sequence of string",
653-
DeprecationWarning,
654-
stacklevel=2,
655-
)
656-
files_or_modules = (files_or_modules,) # type: ignore[assignment]
657646
if self.config.recursive:
658647
files_or_modules = tuple(self._discover_files(files_or_modules))
659648
if self.config.from_stdin:
@@ -669,7 +658,7 @@ def check(self, files_or_modules: Sequence[str] | str) -> None:
669658
}
670659
)
671660

672-
# TODO: Move the parallel invocation into step 5 of the checking process
661+
# TODO: Move the parallel invocation into step 3 of the checking process
673662
if not self.config.from_stdin and self.config.jobs > 1:
674663
original_sys_path = sys.path[:]
675664
check_parallel(
@@ -681,7 +670,7 @@ def check(self, files_or_modules: Sequence[str] | str) -> None:
681670
sys.path = original_sys_path
682671
return
683672

684-
# 3) Get all FileItems
673+
# 1) Get all FileItems
685674
with augmented_sys_path(extra_packages_paths):
686675
if self.config.from_stdin:
687676
fileitems = self._get_file_descr_from_stdin(files_or_modules[0])
@@ -693,10 +682,10 @@ def check(self, files_or_modules: Sequence[str] | str) -> None:
693682
# The contextmanager also opens all checkers and sets up the PyLinter class
694683
with augmented_sys_path(extra_packages_paths):
695684
with self._astroid_module_checker() as check_astroid_module:
696-
# 4) Get the AST for each FileItem
685+
# 2) Get the AST for each FileItem
697686
ast_per_fileitem = self._get_asts(fileitems, data)
698687

699-
# 5) Lint each ast
688+
# 3) Lint each ast
700689
self._lint_files(ast_per_fileitem, check_astroid_module)
701690

702691
def _get_asts(

tests/lint/test_pylinter.py

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from unittest import mock
99
from unittest.mock import patch
1010

11-
from _pytest.recwarn import WarningsRecorder
1211
from pytest import CaptureFixture
1312

1413
from pylint.lint.pylinter import PyLinter
@@ -34,12 +33,6 @@ def test_crash_in_file(
3433
assert any(m.symbol == "fatal" for m in linter.reporter.messages)
3534

3635

37-
def test_check_deprecation(linter: PyLinter, recwarn: WarningsRecorder) -> None:
38-
linter.check("myfile.py")
39-
msg = recwarn.pop()
40-
assert "check function will only accept sequence" in str(msg)
41-
42-
4336
def test_crash_during_linting(
4437
linter: PyLinter, capsys: CaptureFixture[str], tmp_path: Path
4538
) -> None:

0 commit comments

Comments
 (0)