diff --git a/doc/whatsnew/fragments/8463.internal b/doc/whatsnew/fragments/8463.internal new file mode 100644 index 0000000000..de5df25200 --- /dev/null +++ b/doc/whatsnew/fragments/8463.internal @@ -0,0 +1,3 @@ +Following a deprecation period, ``Pylinter.check`` now only work with sequences of strings, not strings. + +Refs #8463 diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 90f7cd75cf..cde21627de 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -637,23 +637,12 @@ def _discover_files(self, files_or_modules: Sequence[str]) -> Iterator[str]: else: yield something - def check(self, files_or_modules: Sequence[str] | str) -> None: + def check(self, files_or_modules: Sequence[str]) -> None: """Main checking entry: check a list of files or modules from their name. files_or_modules is either a string or list of strings presenting modules to check. """ - # 1) Initialize self.initialize() - - # 2) Gather all files - if not isinstance(files_or_modules, (list, tuple)): - # TODO: 3.0: Remove deprecated typing and update docstring - warnings.warn( - "In pylint 3.0, the checkers check function will only accept sequence of string", - DeprecationWarning, - stacklevel=2, - ) - files_or_modules = (files_or_modules,) # type: ignore[assignment] if self.config.recursive: files_or_modules = tuple(self._discover_files(files_or_modules)) if self.config.from_stdin: @@ -669,7 +658,7 @@ def check(self, files_or_modules: Sequence[str] | str) -> None: } ) - # TODO: Move the parallel invocation into step 5 of the checking process + # TODO: Move the parallel invocation into step 3 of the checking process if not self.config.from_stdin and self.config.jobs > 1: original_sys_path = sys.path[:] check_parallel( @@ -681,7 +670,7 @@ def check(self, files_or_modules: Sequence[str] | str) -> None: sys.path = original_sys_path return - # 3) Get all FileItems + # 1) Get all FileItems with augmented_sys_path(extra_packages_paths): if self.config.from_stdin: 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: # The contextmanager also opens all checkers and sets up the PyLinter class with augmented_sys_path(extra_packages_paths): with self._astroid_module_checker() as check_astroid_module: - # 4) Get the AST for each FileItem + # 2) Get the AST for each FileItem ast_per_fileitem = self._get_asts(fileitems, data) - # 5) Lint each ast + # 3) Lint each ast self._lint_files(ast_per_fileitem, check_astroid_module) def _get_asts( diff --git a/tests/lint/test_pylinter.py b/tests/lint/test_pylinter.py index 6ccce8fca7..f7e7cf4c47 100644 --- a/tests/lint/test_pylinter.py +++ b/tests/lint/test_pylinter.py @@ -8,7 +8,6 @@ from unittest import mock from unittest.mock import patch -from _pytest.recwarn import WarningsRecorder from pytest import CaptureFixture from pylint.lint.pylinter import PyLinter @@ -34,12 +33,6 @@ def test_crash_in_file( assert any(m.symbol == "fatal" for m in linter.reporter.messages) -def test_check_deprecation(linter: PyLinter, recwarn: WarningsRecorder) -> None: - linter.check("myfile.py") - msg = recwarn.pop() - assert "check function will only accept sequence" in str(msg) - - def test_crash_during_linting( linter: PyLinter, capsys: CaptureFixture[str], tmp_path: Path ) -> None: