Skip to content

Remove set_config_directly #6123

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

Merged
merged 2 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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