This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: RawDescriptionHelpFormatter seems to be ignored for argument descriptions
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: paul.j3, rrt
Priority: normal Keywords:

Created on 2021-04-26 09:29 by rrt, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg391890 - (view) Author: Reuben Thomas (rrt) Date: 2021-04-26 09:29
The documentation seems very clear on this subject:

"RawTextHelpFormatter maintains whitespace for all sorts of help text, including argument descriptions. However, multiple new lines are replaced with one."

But consider the following code:

```
from argparse import ArgumentParser, RawDescriptionHelpFormatter

parser = ArgumentParser(
  description='A simple templating system.',
  epilog='Use `-\' as a file name to indicate standard input or output.',
  formatter_class=RawDescriptionHelpFormatter,
)
parser.add_argument(
  '--verbose',
  help='show on standard error the path being built,\nand the names of files built, included and pasted'
)
args = parser.parse_args()
```

Then try running it in a suitably-sized terminal:

$ python3 test.py --help
usage: test.py [-h] [--verbose VERBOSE]

A simple templating system.

optional arguments:
  -h, --help         show this help message and exit
  --verbose VERBOSE  show on standard error the path being built, and the names of files built, included and pasted

Use `-' as a file name to indicate standard input or output.
```

The \n in the help for the `--verbose` argument is not respected.
msg391891 - (view) Author: Reuben Thomas (rrt) Date: 2021-04-26 09:29
(Tested with Python 3.9.4.)
msg392947 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2021-05-04 20:25
You test with RawDescriptionHelpFormatter, but quote from the RawTextHelpFormatter.
msg392956 - (view) Author: Reuben Thomas (rrt) Date: 2021-05-04 21:09
D'oh! Sorry for the noise. And congratulations to the author/designer of `RawDescriptionHelpFormatter` for designing/implementing exactly what I wanted all along!
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88108
2021-05-04 21:09:10rrtsetstatus: open -> closed
resolution: not a bug
messages: + msg392956

stage: resolved
2021-05-04 20:25:07paul.j3setnosy: + paul.j3
messages: + msg392947
2021-04-26 09:29:51rrtsetmessages: + msg391891
2021-04-26 09:29:05rrtcreate