diff options
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | doc/whatsnew/2.2.rst | 3 | ||||
-rw-r--r-- | pylint/checkers/logging.py | 13 | ||||
-rw-r--r-- | pylint/test/unittest_checker_logging.py | 2 |
4 files changed, 36 insertions, 7 deletions
@@ -2,6 +2,31 @@ Pylint's ChangeLog ------------------ +What's New in Pylint 2.2.2? +========================= + +Release date: 2018-11-28 + +* 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. + + Closes #2614 + + +What's New in Pylint 2.2.1? +========================= + +Release date: 2018-11-27 + +* Fix a crash caused by `implicit-str-concat-in-sequence` and multi-bytes characters. + + Closes #2610 + What's New in Pylint 2.2? ========================= diff --git a/doc/whatsnew/2.2.rst b/doc/whatsnew/2.2.rst index b33d60945..b61a43fd7 100644 --- a/doc/whatsnew/2.2.rst +++ b/doc/whatsnew/2.2.rst @@ -20,6 +20,9 @@ New checkers * ``logging-format-style`` is a new option for the logging checker for usage of str.format() style format strings in calls to loggers. + It accepts two options: ``--logging-format-style=old`` for using `%` style formatting, + which is the assumed default, and ``--logging-format-style=new`` for using `{}` style formatting. + * ``implicit-str-concat-in-sequence`` detects string concatenation inside lists, sets & tuples. Example of code that would generate such warning: 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( """ |