Skip to content

Commit

Permalink
Merge pull request #749 from hhatto/experimental-option-is-deprecated
Browse files Browse the repository at this point in the history
experimental option is deprecated
  • Loading branch information
hhatto authored May 29, 2024
2 parents 83e29b6 + 7253375 commit 6878c96
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -3965,6 +3969,16 @@ 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


Expand Down

0 comments on commit 6878c96

Please sign in to comment.