summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-11-28 09:13:17 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2018-11-28 09:17:20 +0100
commit754ce1dffae4c8e5a1f40decc24ebf03024ab97d (patch)
tree575c20c638f44867d34a0a24fb93fb819243cf8a /pylint
parent484d1720a177454ca783d526c9a55b85c3516016 (diff)
downloadpylint-git-754ce1dffae4c8e5a1f40decc24ebf03024ab97d.tar.gz
Change the ``logging-format-style`` to use name identifier instead of their corresponding Python identifiers
This is to prevent users having to think about escaping the default value for ``logging-format-style`` in the generated config file. Also our config parsing utilities don't quite support escaped values when it comes to ``choices`` detection, so this would have needed various hacks around that. Close #2614
Diffstat (limited to 'pylint')
-rw-r--r--pylint/checkers/logging.py13
-rw-r--r--pylint/test/unittest_checker_logging.py2
2 files changed, 8 insertions, 7 deletions
diff --git a/pylint/checkers/logging.py b/pylint/checkers/logging.py
index 139faf9f4..442cf0ed9 100644
--- a/pylint/checkers/logging.py
+++ b/pylint/checkers/logging.py
@@ -139,11 +139,12 @@ class LoggingChecker(checkers.BaseChecker):
(
"logging-format-style",
{
- "default": "%",
+ "default": "old",
"type": "choice",
- "metavar": "<% or {>",
- "choices": ["%", "{"],
- "help": "Format style used to check logging format string",
+ "metavar": "<old (%) or new ({)>",
+ "choices": ["old", "new"],
+ "help": "Format style used to check logging format string. "
+ "`old` means using % formatting, while `new` is for `{}` formatting.",
},
),
)
@@ -295,7 +296,7 @@ class LoggingChecker(checkers.BaseChecker):
required_num_args = 0
else:
try:
- if self._format_style == "%":
+ if self._format_style == "old":
keyword_args, required_num_args, _, _ = utils.parse_format_string(
format_string
)
@@ -303,7 +304,7 @@ class LoggingChecker(checkers.BaseChecker):
# Keyword checking on logging strings is complicated by
# special keywords - out of scope.
return
- elif self._format_style == "{":
+ elif self._format_style == "new":
keys, num_args, manual_pos_arg = utils.parse_format_method_string(
format_string
)
diff --git a/pylint/test/unittest_checker_logging.py b/pylint/test/unittest_checker_logging.py
index 62891af0b..a1c111c9e 100644
--- a/pylint/test/unittest_checker_logging.py
+++ b/pylint/test/unittest_checker_logging.py
@@ -63,7 +63,7 @@ class TestLoggingModuleDetection(CheckerTestCase):
with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1])):
self.checker.visit_call(stmts[1])
- @set_config(logging_format_style="{")
+ @set_config(logging_format_style="new")
def test_brace_format_style(self):
stmts = astroid.extract_node(
"""