Skip to content

Commit

Permalink
Remove the future_option_parsing keyword (#6253)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord authored Apr 11, 2022
1 parent e4c7f4a commit 7d079d2
Show file tree
Hide file tree
Showing 24 changed files with 11 additions and 75 deletions.
3 changes: 0 additions & 3 deletions pylint/checkers/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class AsyncChecker(checkers.BaseChecker):
),
}

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def open(self):
self._mixin_class_rgx = utils.get_global_option(self, "mixin-class-rgx")
self._async_generators = ["contextlib.asynccontextmanager"]
Expand Down
5 changes: 0 additions & 5 deletions pylint/checkers/base/docstring_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ class DocStringChecker(_BasicChecker):
),
)

def __init__(
self, linter=None, *, future_option_parsing: Literal[None, True] = None
):
_BasicChecker.__init__(self, linter, future_option_parsing=True)

def open(self):
self.linter.stats.reset_undocumented()

Expand Down
19 changes: 2 additions & 17 deletions pylint/checkers/base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt

import functools
import sys
from inspect import cleandoc
from typing import TYPE_CHECKING, Any, Optional

from astroid import nodes

from pylint.config import OptionsProviderMixIn
from pylint.config.arguments_provider import _ArgumentsProvider
from pylint.config.exceptions import MissingArgumentManager
from pylint.constants import _MSG_ORDER, WarningScope
from pylint.exceptions import InvalidMessageError
from pylint.interfaces import Confidence, IRawChecker, ITokenChecker, implements
from pylint.message.message_definition import MessageDefinition
from pylint.typing import Options
from pylint.utils import get_rst_section, get_rst_title

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
from pylint.lint import PyLinter

Expand All @@ -44,22 +37,14 @@ class BaseChecker(_ArgumentsProvider, OptionsProviderMixIn):
# mark this checker as enabled or not.
enabled: bool = True

def __init__(
self, linter: "PyLinter", *, future_option_parsing: Literal[None, True] = None
):
def __init__(self, linter: "PyLinter") -> None:
"""Checker instances should have the linter as argument."""
if self.name is not None:
self.name = self.name.lower()
_ArgumentsProvider.__init__(self, linter)
self.linter = linter
OptionsProviderMixIn.__init__(self)

if future_option_parsing:
# We need a PyLinter object that subclasses _ArgumentsManager to register options
if not linter:
raise MissingArgumentManager

_ArgumentsProvider.__init__(self, linter)

def __gt__(self, other):
"""Permit to sort a list of Checker by name."""
return f"{self.name}{self.msgs}" > f"{other.name}{other.msgs}"
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/classes/class_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ class ClassChecker(BaseChecker):
)

def __init__(self, linter=None):
super().__init__(linter, future_option_parsing=True)
super().__init__(linter)
self._accessed = ScopeAccessMap()
self._first_attrs = []
self._meth_could_be_func = None
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/design_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class MisdesignChecker(BaseChecker):
)

def __init__(self, linter=None):
super().__init__(linter, future_option_parsing=True)
super().__init__(linter)
self._returns = None
self._branches = None
self._stmts = None
Expand Down
3 changes: 0 additions & 3 deletions pylint/checkers/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ class ExceptionsChecker(checkers.BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def open(self):
self._builtin_exceptions = _builtin_exceptions()
super().open()
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class FormatChecker(BaseTokenChecker):
)

def __init__(self, linter=None):
super().__init__(linter, future_option_parsing=True)
super().__init__(linter)
self._lines = None
self._visited_lines = None
self._bracket_stack = [None]
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class ImportsChecker(DeprecatedMixin, BaseChecker):
)

def __init__(self, linter: "PyLinter") -> None:
BaseChecker.__init__(self, linter, future_option_parsing=True)
BaseChecker.__init__(self, linter)
self.import_graph: collections.defaultdict = collections.defaultdict(set)
self._imports_stack: List[Tuple[Any, Any]] = []
self._first_non_import_node = None
Expand Down
3 changes: 0 additions & 3 deletions pylint/checkers/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ class LoggingChecker(checkers.BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter=linter, future_option_parsing=True)

def visit_module(self, _: nodes.Module) -> None:
"""Clears any state left in this checker from last module checked."""
# The code being checked can just as easily "import logging as foo",
Expand Down
3 changes: 0 additions & 3 deletions pylint/checkers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ class EncodingChecker(BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def open(self):
super().open()

Expand Down
3 changes: 0 additions & 3 deletions pylint/checkers/raw_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class RawMetricsChecker(BaseTokenChecker):
# reports
reports = (("RP0701", "Raw metrics", report_raw_stats),)

def __init__(self, linter):
super().__init__(linter)

def open(self):
"""Init statistics."""
self.linter.stats.reset_code_count()
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/refactoring/refactoring_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class RefactoringChecker(checkers.BaseTokenChecker):
)

def __init__(self, linter):
super().__init__(linter, future_option_parsing=True)
super().__init__(linter)
self._return_nodes = {}
self._consider_using_with_stack = ConsiderUsingWithStack()
self._init()
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ class SimilarChecker(BaseChecker, Similar, MapReduceMixin):
reports = (("RP0801", "Duplication", report_similarities),)

def __init__(self, linter=None) -> None:
BaseChecker.__init__(self, linter, future_option_parsing=True)
BaseChecker.__init__(self, linter)
Similar.__init__(
self,
min_lines=self.linter.namespace.min_similarity_lines,
Expand Down
3 changes: 0 additions & 3 deletions pylint/checkers/spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ class SpellingChecker(BaseTokenChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def open(self):
self.initialized = False
self.private_dict_file = None
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ class StringConstantChecker(BaseTokenChecker):
UNICODE_ESCAPE_CHARACTERS = "uUN"

def __init__(self, linter):
super().__init__(linter, future_option_parsing=True)
super().__init__(linter)
self.string_tokens = {} # token position -> (token value, next token)

def process_module(self, node: nodes.Module) -> None:
Expand Down
6 changes: 0 additions & 6 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,6 @@ class TypeChecker(BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def open(self) -> None:
py_version = get_global_option(self, "py-version")
self._py310_plus = py_version >= (3, 10)
Expand Down Expand Up @@ -2030,9 +2027,6 @@ class IterableChecker(BaseChecker):
),
}

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

@staticmethod
def _is_asyncio_coroutine(node):
if not isinstance(node, nodes.Call):
Expand Down
4 changes: 0 additions & 4 deletions pylint/config/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ class UnrecognizedArgumentAction(Exception):
"""


class MissingArgumentManager(Exception):
"""Raised if an ArgumentManager instance to register options to is missing."""


class ArgumentPreprocessingError(Exception):
"""Raised if an error occurs during argument preprocessing."""
3 changes: 0 additions & 3 deletions pylint/extensions/bad_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class BadBuiltinChecker(BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

@check_messages("bad-builtin")
def visit_call(self, node: nodes.Call) -> None:
if isinstance(node.func, nodes.Name):
Expand Down
3 changes: 0 additions & 3 deletions pylint/extensions/broad_try_clause.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class BroadTryClauseChecker(checkers.BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def _count_statements(self, try_node):
statement_count = len(try_node.body)

Expand Down
4 changes: 0 additions & 4 deletions pylint/extensions/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ class CodeStyleChecker(BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
"""Initialize checker instance."""
super().__init__(linter=linter, future_option_parsing=True)

def open(self) -> None:
py_version = get_global_option(self, "py-version")
self._py38_plus = py_version >= (3, 8)
Expand Down
3 changes: 0 additions & 3 deletions pylint/extensions/docparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ class DocstringParameterChecker(BaseChecker):
constructor_names = {"__init__", "__new__"}
not_needed_param_in_docstring = {"self", "cls"}

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

def visit_functiondef(self, node: nodes.FunctionDef) -> None:
"""Called for function and method definitions (def).
Expand Down
3 changes: 0 additions & 3 deletions pylint/extensions/mccabe.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ class McCabeMethodChecker(checkers.BaseChecker):
),
)

def __init__(self, linter: "PyLinter") -> None:
super().__init__(linter, future_option_parsing=True)

@check_messages("too-complex")
def visit_module(self, node: nodes.Module) -> None:
"""Visit an astroid.Module node to check too complex rating and
Expand Down
2 changes: 1 addition & 1 deletion pylint/extensions/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class TypingChecker(BaseChecker):

def __init__(self, linter: "PyLinter") -> None:
"""Initialize checker instance."""
super().__init__(linter=linter, future_option_parsing=True)
super().__init__(linter=linter)
self._found_broken_callable_location: bool = False
self._alias_name_collisions: Set[str] = set()
self._deprecated_typing_alias_msgs: List[DeprecatedTypingAliasMsg] = []
Expand Down
2 changes: 1 addition & 1 deletion pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def __init__(
self._by_id_managed_msgs: List[ManagedMessage] = []

reporters.ReportsHandlerMixIn.__init__(self)
checkers.BaseTokenChecker.__init__(self, self, future_option_parsing=True)
checkers.BaseTokenChecker.__init__(self, self)
# provided reports
self.reports = (
("RP0001", "Messages by category", report_total_messages_stats),
Expand Down

0 comments on commit 7d079d2

Please sign in to comment.