Skip to content

gh-126676: Expand argparse docs for type=bool with warning and alternatives#146435

Merged
savannahostrowski merged 3 commits intopython:mainfrom
joshuaswanson:fix/argparse-bool-docs
Apr 3, 2026
Merged

gh-126676: Expand argparse docs for type=bool with warning and alternatives#146435
savannahostrowski merged 3 commits intopython:mainfrom
joshuaswanson:fix/argparse-bool-docs

Conversation

@joshuaswanson
Copy link
Copy Markdown
Contributor

@joshuaswanson joshuaswanson commented Mar 25, 2026

Replace the brief type=bool note with a .. warning:: admonition that demonstrates the surprising behavior ('False' -> True), and add three recommended alternatives: BooleanOptionalAction, store_true/store_false, and a custom converter function.

Addresses the request in #126676 (comment) for documenting "recipes/patterns to achieve the desired result." This is a docs-only change with no runtime behavior modifications.

Copy link
Copy Markdown
Member

@savannahostrowski savannahostrowski left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this. Left a comment about trying to be more concise!

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 3, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@joshuaswanson
Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again. Removed the warning admonition and condensed the alternatives to a single line pointing to BooleanOptionalAction and store_true.

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 3, 2026

Thanks for making the requested changes!

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

@bedevere-app bedevere-app bot requested a review from savannahostrowski April 3, 2026 17:46
@savannahostrowski savannahostrowski added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Apr 3, 2026
@savannahostrowski savannahostrowski enabled auto-merge (squash) April 3, 2026 18:01
@savannahostrowski savannahostrowski merged commit 80d0a85 into python:main Apr 3, 2026
30 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Apr 3, 2026
@miss-islington-app
Copy link
Copy Markdown

Thanks @joshuaswanson for the PR, and @savannahostrowski for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 3, 2026
…alternatives (pythonGH-146435)

(cherry picked from commit 80d0a85)

Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
Co-authored-by: joshuaswanson <joshuaswanson@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 3, 2026
…alternatives (pythonGH-146435)

(cherry picked from commit 80d0a85)

Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
Co-authored-by: joshuaswanson <joshuaswanson@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 3, 2026

GH-148048 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Apr 3, 2026
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 3, 2026

GH-148049 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Apr 3, 2026
savannahostrowski added a commit that referenced this pull request Apr 3, 2026
… alternatives (GH-146435) (#148049)

gh-126676: Expand argparse docs for type=bool with warning and alternatives (GH-146435)
(cherry picked from commit 80d0a85)

Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
Co-authored-by: joshuaswanson <joshuaswanson@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
savannahostrowski added a commit that referenced this pull request Apr 3, 2026
… alternatives (GH-146435) (#148048)

gh-126676: Expand argparse docs for type=bool with warning and alternatives (GH-146435)
(cherry picked from commit 80d0a85)

Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
Co-authored-by: joshuaswanson <joshuaswanson@users.noreply.github.com>
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

docs Documentation in the Doc dir

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants