Skip to content

gh-138697: Fix inferring dest from a single-dash long option in argparse - #138699

Merged
savannahostrowski merged 5 commits into
python:mainfrom
serhiy-storchaka:argparse-single-dash-long-option-dest
Nov 20, 2025
Merged

gh-138697: Fix inferring dest from a single-dash long option in argparse#138699
savannahostrowski merged 5 commits into
python:mainfrom
serhiy-storchaka:argparse-single-dash-long-option-dest

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 9, 2025

Copy link
Copy Markdown
Member

If a short option and a single-dash long option are passed to add_argument(), dest is now inferred from the single-dash long option.


📚 Documentation preview 📚: https://cpython-previews--138699.org.readthedocs.build/

… argparse

If a short option and a single-dash long option are passed to add_argument(),
dest is now inferred from the single-dash long option.
@serhiy-storchaka
serhiy-storchaka force-pushed the argparse-single-dash-long-option-dest branch from 9987fa1 to 426169f Compare September 9, 2025 10:14
@serhiy-storchaka serhiy-storchaka linked an issue Sep 19, 2025 that may be closed by this pull request

@savannahostrowski savannahostrowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I am supportive of making dest more consistent so thanks for opening this issue and PR. However, there is one edge case that still needs to be addressed.

Comment thread Lib/argparse.py Outdated
@bedevere-app

bedevere-app Bot commented Nov 20, 2025

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again.

@bedevere-app

bedevere-app Bot commented Nov 20, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@savannahostrowski: please review the changes made to this pull request.

@savannahostrowski savannahostrowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this!

@savannahostrowski
savannahostrowski enabled auto-merge (squash) November 20, 2025 18:11
@savannahostrowski
savannahostrowski merged commit 77cb39e into python:main Nov 20, 2025
46 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the argparse-single-dash-long-option-dest branch November 20, 2025 19:26
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
… argparse (python#138699)

* pythongh-138697: Fix inferring dest from a single-dash long option in argparse

If a short option and a single-dash long option are passed to add_argument(),
dest is now inferred from the single-dash long option.

* Make double-dash options taking priority over single-dash long options.

---------

Co-authored-by: Savannah Ostrowski <savannah@python.org>
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull request Dec 8, 2025
… argparse (python#138699)

* pythongh-138697: Fix inferring dest from a single-dash long option in argparse

If a short option and a single-dash long option are passed to add_argument(),
dest is now inferred from the single-dash long option.

* Make double-dash options taking priority over single-dash long options.

---------

Co-authored-by: Savannah Ostrowski <savannah@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inferring dest from a single-dash long option

2 participants