-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Inferring dest from a single-dash long option #138697
Copy link
Copy link
Closed
Labels
3.15new features, bugs and security fixesnew features, 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
Metadata
Metadata
Assignees
Labels
3.15new features, bugs and security fixesnew features, 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
Projects
Status
Doc issues
Bug report
In
argparse, in general, short options are options that consist of a single character preceded by a dash (e.g.-f), and long options are either preceded by a double dash or are longer that a single character (e.g.--fooand-foo). Short option can be combined together and can have value immediately following an option, long options should be separate and have explicit separation from value.But when
destis inferred from the option strings, single-dash long options are treated as short options. For example, inadd_argument('-f', '--foo')dest is'foo', but inadd_argument('-f', '-foo')dest is'f'.This inconsistency should be fixed. But since this is a breaking change, it should not be backported.
I doubt it will break much user code (it did not broke existing tests), because it only affects the code that uses both short option and single-dash long option for the same argument, place the short option option first, and does not have explicit
destargument. Users that use short options and single-dash long options most likely use workarounds: either place the single-dash long option first or add an explicitdestargument.Linked PRs