You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optional multi-value option returns empty tuple instead of None.
To Reproduce
Create a file main.py with:
fromtypingimportList, Optionalimporttyperapp=typer.Typer()
@app.command()defmain(jobs: Optional[List[str]] =None): # or `typer.Option(None)`print(jobs)
if__name__=="__main__":
app()
Call it with:
python main.py
It outputs:
()
But I expected it to output:
None
Expected behavior
The expected behavior for an empty parameter annotated with Optional and = None is both documented and commonly known - it should be just None. And that's also how it works in Typer, but for some reason - only for single-value options.
Environment
OS: macOS
Typer version: 0.3.2
Python version: 3.8.5
The text was updated successfully, but these errors were encountered:
Confirmed that this still seems like an issue, though the output on the current version of Typer v0.9.0 is [], not () (which is still not the expected None)
Describe the bug
Optional multi-value option returns empty tuple instead of
None
.To Reproduce
main.py
with:Expected behavior
The expected behavior for an empty parameter annotated with
Optional
and= None
is both documented and commonly known - it should be justNone
. And that's also how it works in Typer, but for some reason - only for single-value options.Environment
The text was updated successfully, but these errors were encountered: