Skip to content

gh-127296: Document that argparse count action starts from a non-zero default - #156908

Merged
savannahostrowski merged 3 commits into
python:mainfrom
owenthcarey:gh-127296-argparse-count-default
Sep 5, 2026
Merged

gh-127296: Document that argparse count action starts from a non-zero default#156908
savannahostrowski merged 3 commits into
python:mainfrom
owenthcarey:gh-127296-argparse-count-default

Conversation

@owenthcarey

@owenthcarey owenthcarey commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

The 'count' action adds to whatever value is already in the namespace, so with default=3 a single -v gives 4, not 1. The docs don't say this, and the general description of default reads as if the default is only used when the argument is absent.

This adds one sentence to the 'count' entry saying that a non-zero default is the starting point for the count, as suggested in the issue.

Fixes #127296

@read-the-docs-community

read-the-docs-community Bot commented Sep 3, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34409315 | 📁 Comparing 7cb271d against main (c8ea867)

  🔍 Preview build  

7 files changed · ± 7 modified

± Modified

Comment thread Doc/library/argparse.rst Outdated
@savannahostrowski savannahostrowski added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 4, 2026
Co-authored-by: Savannah Ostrowski <savannah@python.org>
@owenthcarey

Copy link
Copy Markdown
Contributor Author

Thanks! Applied your suggestion.

@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.

Thank you!

@savannahostrowski
savannahostrowski enabled auto-merge (squash) September 5, 2026 16:52
@savannahostrowski
savannahostrowski merged commit 7a91841 into python:main Sep 5, 2026
30 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Sep 5, 2026
@miss-islington-app

Copy link
Copy Markdown

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

@bedevere-app

bedevere-app Bot commented Sep 5, 2026

Copy link
Copy Markdown

GH-156997 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 5, 2026
@bedevere-app

bedevere-app Bot commented Sep 5, 2026

Copy link
Copy Markdown

GH-156998 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 Sep 5, 2026
@bedevere-app

bedevere-app Bot commented Sep 5, 2026

Copy link
Copy Markdown

GH-156999 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 Sep 5, 2026
savannahostrowski added a commit that referenced this pull request Sep 5, 2026
…on-zero default (GH-156908) (#156998)

gh-127296: Document that argparse count action starts from a non-zero default (GH-156908)
(cherry picked from commit 7a91841)

Co-authored-by: Owen Carey <37121709+owenthcarey@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
savannahostrowski added a commit that referenced this pull request Sep 5, 2026
…on-zero default (GH-156908) (#156999)

gh-127296: Document that argparse count action starts from a non-zero default (GH-156908)
(cherry picked from commit 7a91841)

Co-authored-by: Owen Carey <37121709+owenthcarey@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 skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Argparse: "default" interacts incorrectly/non-intuitively with action="count"

2 participants