Skip to content

🐛 Ensure that an envvar set for typer.Option works as expected#1788

Merged
tiangolo merged 2 commits into
fastapi:masterfrom
svlandeg:fix/opt-envvar
May 26, 2026
Merged

🐛 Ensure that an envvar set for typer.Option works as expected#1788
tiangolo merged 2 commits into
fastapi:masterfrom
svlandeg:fix/opt-envvar

Conversation

@svlandeg
Copy link
Copy Markdown
Member

@svlandeg svlandeg commented May 26, 2026

Fixes #1787, thanks to @wpk-nist-gov for the report in #1786.

Description

In the Click vendoring PR leading up to release 0.26.0, at a certain point I merged Click's Option with TyperOption. For the function value_from_envvar (original here) I removed some flag-related stuff that shouldn't be relevant to Typer, but I must have mistakingly also removed the final return statement return rv when there is a relevant envvar set. The commit that produced this bug was this one.

There wasn't a regression test to catch this, so this PR adds one.

AI Disclaimer

Used Cursor to help me debug the issue more quickly, manually reviewed everything in detail.

Checklist

  • I added tests for the change.
  • The new or updated tests fail on the main branch and pass on this PR.
  • Coverage stays at 100%.

@svlandeg svlandeg changed the title Fix/opt envvar 🐛 Ensure that an envvar set for typer.Option works as expected May 26, 2026
@svlandeg svlandeg added the bug Something isn't working label May 26, 2026
@svlandeg svlandeg marked this pull request as ready for review May 26, 2026 17:32
Copy link
Copy Markdown
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

Awesome, thanks! So fast. 🚤

This will be available in Typer 0.26.1 in the next few minutes.

@tiangolo tiangolo merged commit 3028854 into fastapi:master May 26, 2026
22 of 23 checks passed
@svlandeg svlandeg deleted the fix/opt-envvar branch May 26, 2026 17:46
Comment thread typer/core.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: envvar not working for typer.Options with typer==0.26.0

3 participants