shot of post - πŸ’­ Document how to provide a negative number as an argument Β· fas...

Here's my thought on πŸ’­ Document how to provide a negative number as an argument Β· fas...


Today I learned that you cannot pass negative integers as values to typer. in this case context_settings={"ignore_unknown_options": True} is required so that the - does not look like a flag.

# script name: main.py

import typer

app = typer.Typer()

@app.command() def failing(value: float): print(f"{value=}")

@app.command( context_settings={"ignore_unknown_options": True} ) def working_good(value: float): print(f"{value=}")

if name == "main": app()


!!! note This post is a thought. It's a short note that I make about someone else's content online. Learn more about the process [[ thoughts ]]

{.text-opacity-80} This post was a thought by Waylon Walker see all my thoughts at https://waylonwalker.com/thoughts