Skip to content

Commit

Permalink
Remove use of deprecated methods in _ArgumentsProvider and ``_con…
Browse files Browse the repository at this point in the history
…fig_initialization``
  • Loading branch information
DanielNoord committed Apr 13, 2022
1 parent a542164 commit 01676ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 35 deletions.
3 changes: 0 additions & 3 deletions pylint/config/arguments_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ def __init__(self, arguments_manager: _ArgumentsManager) -> None:
# TODO: Optparse: Added to keep API parity with OptionsProvider
# They should be removed/deprecated when refactoring the copied methods
self._config = optparse.Values()
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self.load_defaults()
self.level = 0

@property
Expand Down
32 changes: 0 additions & 32 deletions pylint/config/config_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt

import sys
import warnings
from pathlib import Path
from typing import TYPE_CHECKING, List, Union

Expand Down Expand Up @@ -48,37 +47,6 @@ def _config_initialization(
if "load-plugins" in config_data:
linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))

# pylint: disable-next=fixme
# TODO: Remove everything until set_reporter once the optparse
# implementation is no longer needed
# Load optparse command line arguments
try:
# The parser is stored on linter.cfgfile_parser
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
linter.read_config_file(config_file=config_file, verbose=verbose_mode)
except OSError as ex:
print(ex, file=sys.stderr)
sys.exit(32)

# Now we can load file config, plugins (which can
# provide options) have been registered
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
linter.load_config_file()

# pylint: disable-next=fixme
# TODO: Optparse: This has been disabled pre-maturely because it interferes with
# argparse option parsing for 'disable' and 'enable'.
# try:
# with warnings.catch_warnings():
# warnings.filterwarnings("ignore", category=DeprecationWarning)
# linter.load_command_line_configuration(args_list)
# except SystemExit as exc:
# if exc.code == 2: # bad options
# exc.code = 32
# raise

# First we parse any options from a configuration file
linter._parse_configuration_file(config_args)

Expand Down
15 changes: 15 additions & 0 deletions tests/config/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,18 @@ def test_register_options_provider_load_defaults(self) -> None:
self.linter.register_options_provider(checker)
with pytest.warns(DeprecationWarning):
self.linter.load_defaults()

def test_read_config_file(self) -> None:
"""Test that read_config_file emits a DeprecationWarning."""
with pytest.warns(DeprecationWarning):
self.linter.read_config_file()

def test_load_config_file(self) -> None:
"""Test that load_config_file emits a DeprecationWarning."""
with pytest.warns(DeprecationWarning):
self.linter.load_config_file()

def test_load_command_line_configuration(self) -> None:
"""Test that load_command_line_configuration emits a DeprecationWarning."""
with pytest.warns(DeprecationWarning):
self.linter.load_command_line_configuration([])

0 comments on commit 01676ae

Please sign in to comment.