Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot use format specifiers in argparse help #142950

Copy link
Copy link
@savannahostrowski

Description

@savannahostrowski
Issue body actions

#141940 caused a regression where users cannot use format specifiers.


See this as an example

my_parser.add_argument(
        "--foo",
        type=int,
        default=1234,
        help=f"""0x%(default)x""",
    )

The above works in 3.14.2, but not in 3.15 alpha3. I apologize if my code is doing something incorrect.

The error I get is

Traceback (most recent call last):
  File "[...]/3.15.0a3/lib/python3.15/argparse.py", line 1793, in _check_help
    formatter._expand_help(action)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "[...]/3.15.0a3/lib/python3.15/argparse.py", line 696, in _expand_help
    return help_string % params
           ~~~~~~~~~~~~^~~~~~~~
TypeError: %x format: an integer is required, not str

Originally posted by @oyvindronningstad in #141940 (comment)

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Labels

3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
No fields configured for issues without a type.

Projects

Status
Doc issues
Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.