diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2023-03-20 21:57:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 20:57:06 +0000 |
commit | 66f46bf8bafc44d0417828415b2c1223c028366a (patch) | |
tree | 900c6576fdfa864ad3eaabb3a40a16b601c12161 | |
parent | 5a72e22b350ce717ebf1f693d3ca9a0edc343839 (diff) | |
download | pylint-git-66f46bf8bafc44d0417828415b2c1223c028366a.tar.gz |
[deprecation] 'Pylinter.check' now takes sequence of str only (#8463)
-rw-r--r-- | doc/whatsnew/fragments/8463.internal | 3 | ||||
-rw-r--r-- | pylint/lint/pylinter.py | 21 | ||||
-rw-r--r-- | tests/lint/test_pylinter.py | 7 |
3 files changed, 8 insertions, 23 deletions
diff --git a/doc/whatsnew/fragments/8463.internal b/doc/whatsnew/fragments/8463.internal new file mode 100644 index 000000000..de5df2520 --- /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 90f7cd75c..cde21627d 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -637,23 +637,12 @@ class PyLinter( 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 @@ class PyLinter( } ) - # 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 @@ class PyLinter( 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 @@ class PyLinter( # 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 6ccce8fca..f7e7cf4c4 100644 --- a/tests/lint/test_pylinter.py +++ b/tests/lint/test_pylinter.py @@ -8,7 +8,6 @@ from typing import Any, NoReturn 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: |