Skip to content

Return the supplied default for missing raw options - #549

Open
rupayon123 wants to merge 2 commits into
python-poetry:mainfrom
rupayon123:fix/raw-option-default
Open

rupayon123 wants to merge 2 commits into
python-poetry:mainfrom
rupayon123:fix/raw-option-default

Conversation

@rupayon123

@rupayon123 rupayon123 commented Oct 27, 2026 •

Copy link
Copy Markdown

ArgvInput.parameter_option("--name", default="fallback") returns False when no token matches. Its existing end-of-options branch already returns the supplied default.

Return that default after an exhausted scan too. Tests cover empty and unrelated tokens, single/list option names, False, 0, None, string and object defaults, plus present values and -- controls. The separate attached-value work in #538 is untouched.

Validation on macOS arm64/CPython 3.13.14 with dependencies from poetry.lock: 274 tests pass, three existing skips; mypy, all-file pre-commit checks, package build and built-wheel API checks pass. The inherited NO_COLOR=1 environment triggers the same existing FORCE_COLOR test failure on the pristine base; the passing full run unsets that inherited variable. Other Python/OS combinations were not run locally.

Includes the required news/549.bugfix.md changelog entry.

@rupayon123
rupayon123 marked this pull request as ready for review October 27, 2026 14:20

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked both absence paths in parameter_option: reaching -- with only_params=True already returned the caller’s default, but exhausting _tokens returned False. This change makes those paths consistent while preserving False for callers that omit the argument. The added cases also check 0, None, and an object by identity, so falsy or sentinel defaults are not accidentally replaced; the present-option and -- controls cover the surrounding behavior. I reviewed the diff and method; I did not run tests locally.

This branch has not been deployed

No deployments
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.

2 participants