From 53a993ec09142414a8798b197781e11a2f97bbfb Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Wed, 29 May 2024 09:32:16 +0900 Subject: [PATCH 1/3] experimental option is deprecated --- autopep8.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autopep8.py b/autopep8.py index 437c92f7..31be3a48 100755 --- a/autopep8.py +++ b/autopep8.py @@ -3965,6 +3965,9 @@ def parse_args(arguments, apply_config=False): 'to the second', ) + if args.experimental: + warnings.warn("`experimental` option is deprecated and will be removed in a future version.", DeprecationWarning) + return args From f516b2971af28c5ffa218694d94d9af318c79666 Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Wed, 29 May 2024 09:51:37 +0900 Subject: [PATCH 2/3] use custom warning format --- autopep8.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autopep8.py b/autopep8.py index 31be3a48..78d2e7dc 100755 --- a/autopep8.py +++ b/autopep8.py @@ -159,6 +159,10 @@ class documentation for more information. IS_SUPPORT_TOKEN_FSTRING = True +def _custom_formatwarning(message, category, _, __, line=None): + return f"{category.__name__}: {message}\n" + + def open_with_encoding(filename, mode='r', encoding=None, limit_byte_check=-1): """Return opened file with a specific encoding.""" if not encoding: @@ -3965,8 +3969,11 @@ def parse_args(arguments, apply_config=False): 'to the second', ) + original_formatwarning = warnings.formatwarning + warnings.formatwarning = _custom_formatwarning if args.experimental: warnings.warn("`experimental` option is deprecated and will be removed in a future version.", DeprecationWarning) + warnings.formatwarning = original_formatwarning return args From 725337599eb3c977aa21f4dc05dc5ae416ac4d1d Mon Sep 17 00:00:00 2001 From: Hideo Hattori Date: Wed, 29 May 2024 09:52:09 +0900 Subject: [PATCH 3/3] strict lint --- autopep8.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autopep8.py b/autopep8.py index 78d2e7dc..bcd36e15 100755 --- a/autopep8.py +++ b/autopep8.py @@ -3972,7 +3972,11 @@ def parse_args(arguments, apply_config=False): original_formatwarning = warnings.formatwarning warnings.formatwarning = _custom_formatwarning if args.experimental: - warnings.warn("`experimental` option is deprecated and will be removed in a future version.", DeprecationWarning) + warnings.warn( + "`experimental` option is deprecated and will be " + "removed in a future version.", + DeprecationWarning, + ) warnings.formatwarning = original_formatwarning return args