diff options
-rw-r--r-- | pylint/checkers/base.py | 4 | ||||
-rw-r--r-- | pylint/checkers/similar.py | 2 | ||||
-rw-r--r-- | pylint/checkers/spelling.py | 10 | ||||
-rw-r--r-- | pylint/checkers/utils.py | 4 | ||||
-rw-r--r-- | pylint/config/option.py | 2 | ||||
-rw-r--r-- | pylint/config/option_manager_mixin.py | 2 | ||||
-rw-r--r-- | pylint/extensions/__init__.py | 2 | ||||
-rw-r--r-- | pylint/lint/parallel.py | 4 | ||||
-rw-r--r-- | pylint/lint/pylinter.py | 10 | ||||
-rw-r--r-- | pylint/lint/run.py | 2 | ||||
-rw-r--r-- | pylint/reporters/__init__.py | 2 | ||||
-rw-r--r-- | pylint/reporters/reports_handler_mix_in.py | 2 | ||||
-rw-r--r-- | pylint/testutils/output_line.py | 2 | ||||
-rw-r--r-- | setup.cfg | 1 | ||||
-rw-r--r-- | tests/lint/test_pylinter.py | 2 | ||||
-rw-r--r-- | tests/test_func.py | 4 | ||||
-rw-r--r-- | tests/test_pylint_runners.py | 2 | ||||
-rw-r--r-- | tests/test_self.py | 2 |
18 files changed, 30 insertions, 29 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index fd18fb867..52fae61c5 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -2197,10 +2197,10 @@ class DocStringChecker(_BasicChecker): overridden = True break self._check_docstring( - ftype, node, report_missing=not overridden, confidence=confidence # type: ignore + ftype, node, report_missing=not overridden, confidence=confidence # type: ignore[arg-type] ) elif isinstance(node.parent.frame(), nodes.Module): - self._check_docstring(ftype, node) # type: ignore + self._check_docstring(ftype, node) # type: ignore[arg-type] else: return diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index 4f9a6cb58..4293d5306 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -383,7 +383,7 @@ class Similar: raise ValueError readlines = decoding_stream(stream, encoding).readlines else: - readlines = stream.readlines # type: ignore # hint parameter is incorrectly typed as non-optional + readlines = stream.readlines # type: ignore[assignment] # hint parameter is incorrectly typed as non-optional try: self.linesets.append( LineSet( diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py index 082e21183..f595e796e 100644 --- a/pylint/checkers/spelling.py +++ b/pylint/checkers/spelling.py @@ -52,20 +52,20 @@ try: except ImportError: enchant = None - class EmailFilter: # type: ignore + class EmailFilter: # type: ignore[no-redef] ... - class URLFilter: # type: ignore + class URLFilter: # type: ignore[no-redef] ... - class WikiWordFilter: # type: ignore + class WikiWordFilter: # type: ignore[no-redef] ... - class Filter: # type: ignore + class Filter: # type: ignore[no-redef] def _skip(self, word): raise NotImplementedError - class Chunker: # type: ignore + class Chunker: # type: ignore[no-redef] pass def get_tokenizer( diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index cff791364..62fd35347 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -312,7 +312,7 @@ def is_error(node: nodes.FunctionDef) -> bool: return len(node.body) == 1 and isinstance(node.body[0], nodes.Raise) -builtins = builtins.__dict__.copy() # type: ignore +builtins = builtins.__dict__.copy() # type: ignore[assignment] SPECIAL_BUILTINS = ("__builtins__",) # '__path__', '__file__') @@ -323,7 +323,7 @@ def is_builtin_object(node: nodes.NodeNG) -> bool: def is_builtin(name: str) -> bool: """return true if <name> could be considered as a builtin defined by python""" - return name in builtins or name in SPECIAL_BUILTINS # type: ignore + return name in builtins or name in SPECIAL_BUILTINS # type: ignore[operator] def is_defined_in_scope( diff --git a/pylint/config/option.py b/pylint/config/option.py index 706b7a4af..7093fefe1 100644 --- a/pylint/config/option.py +++ b/pylint/config/option.py @@ -182,7 +182,7 @@ class Option(optparse.Option): ) # pylint: disable=unsupported-assignment-operation - optparse.Option.CHECK_METHODS[2] = _check_choice # type: ignore + optparse.Option.CHECK_METHODS[2] = _check_choice # type: ignore[index] def process(self, opt, value, values, parser): # First, convert the value(s) to the right type. Howl if any diff --git a/pylint/config/option_manager_mixin.py b/pylint/config/option_manager_mixin.py index 587467366..b43a3c27e 100644 --- a/pylint/config/option_manager_mixin.py +++ b/pylint/config/option_manager_mixin.py @@ -309,7 +309,7 @@ class OptionsManagerMixIn: # strings as ConfigParser expects. if not isinstance(values, dict): # This class is a mixin: add_message comes from the `PyLinter` class - self.add_message( # type: ignore + self.add_message( # type: ignore[attr-defined] "bad-configuration-section", line=0, args=(section, values) ) continue diff --git a/pylint/extensions/__init__.py b/pylint/extensions/__init__.py index 96568077c..42477a4b3 100644 --- a/pylint/extensions/__init__.py +++ b/pylint/extensions/__init__.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: def initialize(linter: "PyLinter") -> None: """Initialize linter with checkers in the extensions directory""" - register_plugins(linter, __path__[0]) # type: ignore # Fixed in https://github.com/python/mypy/pull/9454 + register_plugins(linter, __path__[0]) # type: ignore[name-defined] # Fixed in https://github.com/python/mypy/pull/9454 __all__ = ["initialize"] diff --git a/pylint/lint/parallel.py b/pylint/lint/parallel.py index f148e913f..f6bd2aa09 100644 --- a/pylint/lint/parallel.py +++ b/pylint/lint/parallel.py @@ -14,7 +14,7 @@ from pylint.utils import LinterStats, merge_stats try: import multiprocessing except ImportError: - multiprocessing = None # type: ignore + multiprocessing = None # type: ignore[assignment] # PyLinter object used by worker processes when checking files using multiprocessing # should only be used by the worker processes @@ -139,7 +139,7 @@ def check_parallel(linter, jobs, files: Iterable[FileItem], arguments=None): linter.set_current_module(module, file_path) for msg in messages: msg = Message(*msg) - linter.reporter.handle_message(msg) # type: ignore # linter.set_reporter() call above makes linter have a reporter attr + linter.reporter.handle_message(msg) # type: ignore[attr-defined] # linter.set_reporter() call above makes linter have a reporter attr all_stats.append(stats) all_mapreduce_data[worker_idx].append(mapreduce_data) linter.msg_status |= msg_status diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 41f72a70f..72ab3637c 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -974,7 +974,7 @@ class PyLinter( "In pylint 3.0, the checkers check function will only accept sequence of string", DeprecationWarning, ) - files_or_modules = (files_or_modules,) # type: ignore + files_or_modules = (files_or_modules,) # type: ignore[assignment] if self.config.from_stdin: if len(files_or_modules) != 1: raise exceptions.InvalidArgsError( @@ -1336,12 +1336,12 @@ class PyLinter( if confidence is None: confidence = interfaces.UNDEFINED if self.config.confidence and confidence.name not in self.config.confidence: - return MSG_STATE_CONFIDENCE # type: ignore # mypy does not infer Literal correctly + return MSG_STATE_CONFIDENCE # type: ignore[return-value] # mypy does not infer Literal correctly try: if line in self.file_state._module_msgs_state[msgid]: - return MSG_STATE_SCOPE_MODULE # type: ignore + return MSG_STATE_SCOPE_MODULE # type: ignore[return-value] except (KeyError, TypeError): - return MSG_STATE_SCOPE_CONFIG # type: ignore + return MSG_STATE_SCOPE_CONFIG # type: ignore[return-value] return None def _is_one_message_enabled(self, msgid: str, line: Optional[int]) -> bool: @@ -1415,7 +1415,7 @@ class PyLinter( if line is None and node is not None: line = node.fromlineno if col_offset is None and hasattr(node, "col_offset"): - col_offset = node.col_offset # type: ignore + col_offset = node.col_offset # type: ignore[union-attr] # should this message be displayed if not self.is_message_enabled(message_definition.msgid, line, confidence): diff --git a/pylint/lint/run.py b/pylint/lint/run.py index ff2e6a243..7a87d5759 100644 --- a/pylint/lint/run.py +++ b/pylint/lint/run.py @@ -15,7 +15,7 @@ try: import multiprocessing from multiprocessing import synchronize # noqa pylint: disable=unused-import except ImportError: - multiprocessing = None # type: ignore + multiprocessing = None # type: ignore[assignment] def _cpu_count() -> int: diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py index 39cf5fb0a..65231e287 100644 --- a/pylint/reporters/__init__.py +++ b/pylint/reporters/__init__.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: def initialize(linter: "PyLinter") -> None: """initialize linter with reporters in this package""" - utils.register_plugins(linter, __path__[0]) # type: ignore # Fixed in https://github.com/python/mypy/pull/9454 + utils.register_plugins(linter, __path__[0]) # type: ignore[name-defined] # Fixed in https://github.com/python/mypy/pull/9454 __all__ = [ diff --git a/pylint/reporters/reports_handler_mix_in.py b/pylint/reporters/reports_handler_mix_in.py index 14631740d..27af31027 100644 --- a/pylint/reporters/reports_handler_mix_in.py +++ b/pylint/reporters/reports_handler_mix_in.py @@ -57,7 +57,7 @@ class ReportsHandlerMixIn: """ return self._reports_state.get(reportid, True) - def make_reports( # type: ignore # ReportsHandlerMixIn is always mixed with PyLinter + def make_reports( # type: ignore[misc] # ReportsHandlerMixIn is always mixed with PyLinter self: "PyLinter", stats: LinterStats, old_stats: Optional[LinterStats], diff --git a/pylint/testutils/output_line.py b/pylint/testutils/output_line.py index 9a07642e4..9e5a071d2 100644 --- a/pylint/testutils/output_line.py +++ b/pylint/testutils/output_line.py @@ -114,4 +114,4 @@ class OutputLine(NamedTuple): raise MalformedOutputLineException(row, e) from e def to_csv(self) -> Tuple[str, str, str, str, str, str]: - return tuple(str(i) for i in self) # type: ignore # pylint: disable=not-an-iterable + return tuple(str(i) for i in self) # type: ignore[return-value] # pylint: disable=not-an-iterable @@ -86,6 +86,7 @@ src_paths = pylint no_implicit_optional = True scripts_are_modules = True warn_unused_ignores = True +show_error_codes = True [mypy-astroid.*] ignore_missing_imports = True diff --git a/tests/lint/test_pylinter.py b/tests/lint/test_pylinter.py index 15693d024..74ddde2ed 100644 --- a/tests/lint/test_pylinter.py +++ b/tests/lint/test_pylinter.py @@ -3,7 +3,7 @@ from typing import Any from unittest.mock import patch from astroid import AstroidBuildingError -from py._path.local import LocalPath # type: ignore +from py._path.local import LocalPath # type: ignore[import] from pytest import CaptureFixture from pylint.lint.pylinter import PyLinter diff --git a/tests/test_func.py b/tests/test_func.py index 98bdf184a..914fbbc92 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -79,9 +79,9 @@ class LintTestUsingModule: self.linter.check(tocheck) except Exception as ex: print(f"Exception: {ex} in {tocheck}:: {'‚ '.join(ex.args)}") - ex.file = tocheck # type: ignore # This is legacy code we're trying to remove, not worth it to type correctly + ex.file = tocheck # type: ignore[attr-defined] # This is legacy code we're trying to remove, not worth it to type correctly print(ex) - ex.__str__ = exception_str # type: ignore # This is legacy code we're trying to remove, impossible to type correctly + ex.__str__ = exception_str # type: ignore[assignment] # This is legacy code we're trying to remove, impossible to type correctly raise self._check_result(self.linter.reporter.finalize()) diff --git a/tests/test_pylint_runners.py b/tests/test_pylint_runners.py index 84ac05c31..6c4430892 100644 --- a/tests/test_pylint_runners.py +++ b/tests/test_pylint_runners.py @@ -5,7 +5,7 @@ from typing import Callable from unittest.mock import patch import pytest -from py._path.local import LocalPath # type: ignore +from py._path.local import LocalPath # type: ignore[import] from pylint import run_epylint, run_pylint, run_pyreverse, run_symilar diff --git a/tests/test_self.py b/tests/test_self.py index 8441a5acb..2401bb28f 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -56,7 +56,7 @@ from unittest import mock from unittest.mock import patch import pytest -from py._path.local import LocalPath # type: ignore +from py._path.local import LocalPath # type: ignore[import] from pylint import extensions, modify_sys_path from pylint.constants import MAIN_CHECKER_NAME, MSG_TYPES_STATUS |