-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Rename check_messages
#6196
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
Rename check_messages
#6196
Changes from 1 commit
7eb14b2
7645846
58f57ce
49cfc9f
f333f40
135151a
bc4d7f9
21200b8
68d25e1
c241a70
3b89ba5
4751d38
9fd8d7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -434,8 +434,16 @@ def overrides_a_method(class_node: nodes.ClassDef, name: str) -> bool: | |
| return False | ||
|
|
||
|
|
||
| def check_messages(*messages: str) -> Callable: | ||
| """Decorator to store messages that are handled by a checker method.""" | ||
| def only_required_for(*messages: str) -> Callable: | ||
| """Decorator to store messages that are handled by a checker method as an | ||
| attribute of the function object. | ||
|
|
||
| This information is used by ``ASTWalker`` to decide whether to call the decorated | ||
| method or not. If none of the messages is enabled, the method will be skipped. | ||
| Therefore, the list of messages must be well maintained at all times! | ||
| This decorator only has an effect on ``visit_*`` and ``leave_*`` methods | ||
| of a class inheriting from ``BaseChecker`` and implementing ``IAstroidChecker``. | ||
| """ | ||
|
|
||
| def store_messages(func): | ||
| func.checks_msgs = messages | ||
|
|
@@ -444,6 +452,23 @@ def store_messages(func): | |
| return store_messages | ||
|
|
||
|
|
||
| def check_messages(*messages: str) -> Callable: | ||
DudeNr33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """Kept for backwards compatibility, deprecated. | ||
|
|
||
| Use only_required_for instead, which conveys the intent of the decorator much clearer. | ||
| """ | ||
| # Uncomment the following warning once all 'check_messages' calls have been replaced | ||
|
||
| # in pylints codebase. | ||
|
|
||
| # warnings.warn( | ||
| # "utils.check_messages will be removed in favour of calling " | ||
| # "utils.only_required_for in pylint 3.0", | ||
| # DeprecationWarning, | ||
| # ) | ||
|
|
||
| return only_required_for(*messages) | ||
|
|
||
|
|
||
| class IncompleteFormatString(Exception): | ||
| """A format string ended in the middle of a format specifier.""" | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.