hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.54k stars 291 forks source link

Argument parser errors are printed without a trailing newline #713

Closed emanuele6 closed 2 weeks ago

emanuele6 commented 8 months ago

Command Line

$ autopep8
incorrect number of arguments$ autopep8
incorrect number of arguments$

Your Environment

Errors are printed without a trailing newline

emanuele6 commented 8 months ago

I bisected the problem; it was introduced with 24da5065e1fefcf276f60412e90491b578778fde that replaced all calls to parser.error(message) with calls to parser.exit(EXIT_CODE_ARGPARSE_ERROR, message).

Before the change, those argparse errors were displayed as:

$ ./autopep8.py
usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]
                [--ignore-local-config] [-r] [-j n] [-p n] [-a]
                [--experimental] [--exclude globs] [--list-fixes]
                [--ignore errors] [--select errors] [--max-line-length n]
                [--line-range line line] [--hang-closing] [--exit-code]
                [files ...]
autopep8: error: incorrect number of arguments
$ 

Now, they are displayed as:

$ ./autopep8.py
incorrect number of arguments$ # no trailing newline
hhatto commented 2 weeks ago

Thanks for reporting 👍

fix and v2.3.1 has been released. https://pypi.org/project/autopep8/2.3.1/