Skip to content

Commit

Permalink
Remove set_config_directly (#6123)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord authored Apr 2, 2022
1 parent 3418e22 commit 93a1e01
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 51 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Release date: TBA

* Fix bug where specifically enabling just ``await-outside-async`` was not possible.

* The ``set_config_directly`` decorator has been removed.

* Added new message called ``duplicate-value`` which identifies duplicate values inside sets.

Closes #5880
Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Other Changes

* The concept of checker priority has been removed.

* The ``set_config_directly`` decorator has been removed.

* Fix false negative for ``no-member`` when attempting to assign an instance
attribute to itself without any prior assignment.

Expand Down
36 changes: 0 additions & 36 deletions pylint/testutils/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import functools
import optparse # pylint: disable=deprecated-module
import warnings

from pylint.lint import PyLinter
from pylint.testutils.checker_test_case import CheckerTestCase
Expand Down Expand Up @@ -52,38 +51,3 @@ def _forward(self, *args, **test_function_kwargs):
return _forward

return _wrapper


def set_config_directly(**kwargs):
"""Decorator for setting config values on a checker without validation.
Some options should be declared in two different checkers. This is
impossible without duplicating the option key. For example:
"no-docstring-rgx" in DocstringParameterChecker & DocStringChecker
This decorator allows to directly set such options.
Passing the args and kwargs back to the test function itself
allows this decorator to be used on parametrized test cases.
"""
# pylint: disable=fixme
# TODO: Remove this function in 2.14
warnings.warn(
"The set_config_directly decorator will be removed in 2.14. To decorate "
"unittests you can use set_config. If this causes a duplicate KeyError "
"you can consider writing the tests using the functional test framework.",
DeprecationWarning,
)

def _wrapper(fun):
@functools.wraps(fun)
def _forward(self, *args, **test_function_kwargs):
for key, value in kwargs.items():
setattr(self.checker.config, key, value)
if isinstance(self, CheckerTestCase):
# reopen checker in case, it may be interested in configuration change
self.checker.open()
fun(self, *args, **test_function_kwargs)

return _forward

return _wrapper
15 changes: 0 additions & 15 deletions tests/testutils/test_decorator.py

This file was deleted.

0 comments on commit 93a1e01

Please sign in to comment.