Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all old code related to optparse config parsing. #8405

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions doc/exts/pylint_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import os
import re
import sys
import warnings
from typing import Any

import sphinx
Expand Down Expand Up @@ -134,24 +133,20 @@ def get_plugins_info(
doc = f.read()
try:
by_checker[checker]["checker"] = checker
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
by_checker[checker]["options"] += checker.options_and_values()
by_checker[checker]["options"] += checker._options_and_values()
by_checker[checker]["msgs"].update(checker.msgs)
by_checker[checker]["reports"] += checker.reports
by_checker[checker]["doc"] += doc
by_checker[checker]["module"] += module
except KeyError:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
by_checker[checker] = _CheckerInfo(
checker=checker,
options=list(checker.options_and_values()),
msgs=dict(checker.msgs),
reports=list(checker.reports),
doc=doc,
module=module,
)
by_checker[checker] = _CheckerInfo(
checker=checker,
options=list(checker._options_and_values()),
msgs=dict(checker.msgs),
reports=list(checker.reports),
doc=doc,
module=module,
)
return by_checker


Expand Down
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/8405.other
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
All code related to the optparse config parsing has been removed.

Refs #8405
8 changes: 3 additions & 5 deletions pylint/checkers/base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ def __str__(self) -> str:

See: MessageHandlerMixIn.get_full_documentation()
"""
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
return self.get_full_documentation(
msgs=self.msgs, options=self.options_and_values(), reports=self.reports
)
return self.get_full_documentation(
msgs=self.msgs, options=self._options_and_values(), reports=self.reports
)

def get_full_documentation(
self,
Expand Down
62 changes: 2 additions & 60 deletions pylint/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,6 @@

from __future__ import annotations

__all__ = [
"ConfigurationMixIn", # Deprecated
"find_default_config_files",
"find_pylintrc", # Deprecated
"Option", # Deprecated
"OptionsManagerMixIn", # Deprecated
"OptionParser", # Deprecated
"OptionsProviderMixIn", # Deprecated
"UnsupportedAction", # Deprecated
"PYLINTRC",
"USER_HOME", # Compatibility with the old API
"PYLINT_HOME", # Compatibility with the old API
"save_results", # Compatibility with the old API # Deprecated
"load_results", # Compatibility with the old API # Deprecated
]
__all__ = ["find_default_config_files"]

import warnings

from pylint.config.arguments_provider import UnsupportedAction
from pylint.config.configuration_mixin import ConfigurationMixIn
from pylint.config.environment_variable import PYLINTRC
from pylint.config.find_default_config_files import (
find_default_config_files,
find_pylintrc,
)
from pylint.config.option import Option
from pylint.config.option_manager_mixin import OptionsManagerMixIn
from pylint.config.option_parser import OptionParser # type: ignore[attr-defined]
from pylint.config.options_provider_mixin import ( # type: ignore[attr-defined]
OptionsProviderMixIn,
)
from pylint.constants import PYLINT_HOME, USER_HOME
from pylint.utils import LinterStats


def load_results(base: str) -> LinterStats | None:
# TODO: 3.0: Remove deprecated function
# pylint: disable=import-outside-toplevel
from pylint.lint.caching import load_results as _real_load_results

warnings.warn(
"'pylint.config.load_results' is deprecated, please use "
"'pylint.lint.load_results' instead. This will be removed in 3.0.",
DeprecationWarning,
stacklevel=2,
)
return _real_load_results(base, PYLINT_HOME)


def save_results(results: LinterStats, base: str) -> None:
# TODO: 3.0: Remove deprecated function
# pylint: disable=import-outside-toplevel
from pylint.lint.caching import save_results as _real_save_results

warnings.warn(
"'pylint.config.save_results' is deprecated, please use "
"'pylint.lint.save_results' instead. This will be removed in 3.0.",
DeprecationWarning,
stacklevel=2,
)
return _real_save_results(results, base, PYLINT_HOME)
from pylint.config.find_default_config_files import find_default_config_files
7 changes: 2 additions & 5 deletions pylint/config/_pylint_config/generate_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from __future__ import annotations

import warnings
from io import StringIO
from typing import TYPE_CHECKING

Expand All @@ -29,10 +28,8 @@ def generate_interactive_config(linter: PyLinter) -> None:
config_string = linter._generate_config_file(minimal=minimal)
else:
output_stream = StringIO()
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
linter.generate_config(stream=output_stream, skipsections=("Commands",))
config_string = output_stream.getvalue()
linter._generate_config(stream=output_stream, skipsections=("Commands",))
config_string = output_stream.getvalue()

if to_file:
with open(output_file_name, "w", encoding="utf-8") as f:
Expand Down
Loading