Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small clarification in the tutorial docs for cli arguments #990

Closed
wants to merge 1 commit into from

Conversation

mina58
Copy link

@mina58 mina58 commented Sep 15, 2024

In the optional cli arguments section, it said "To make a CLI argument optional, use typer.Argument() and pass a different "default" as the first parameter to typer.Argument(), for example None:" and the example was:

from typing import Optional

import typer
from typing_extensions import Annotated


def main(name: Annotated[Optional[str], typer.Argument()] = None):
    if name is None:
        print("Hello World!")
    else:
        print(f"Hello {name}")


if __name__ == "__main__":
    typer.run(main)

I thought it was confusing because when I read it for the first time i though i should write it like this

def main(name: Annotated[Optional[str], typer.Argument(default=None)]) -> None

which is wrong, so i clarified the text a little.

@github-actions github-actions bot added the docs Improvements or additions to documentation label Sep 15, 2024
Copy link

@svlandeg
Copy link
Member

Hi, thanks for the PR!

This particular sentence in the documentation is already being addressed by #983, so I'll go ahead and close this one. Thanks again though!

@svlandeg svlandeg closed this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants