TypeError - <argument/option name> is defined twice #834
Replies: 3 comments
-
Whenever I use |
Beta Was this translation helpful? Give feedback.
-
So I ended up here due to getting the same error. My issue was, however, completely different. With the code input_folder: str = typer.Option(
None,
"--input-folder",
"in",
help="Folder where ALL the reference data is present"
), I get the error: If I change the declaration |
Beta Was this translation helpful? Give feedback.
-
Try removing the “default” values from typer.Option(). It should help. @solr_app.command("download")
def download(
version: Annotated[
str,
typer.Option(
"--version",
help="The version of the Solr KG to download (latest, dev, or a specific version)",
),
] = "latest",
overwrite: Annotated[
bool,
typer.Option(
"--overwrite",
help="Overwrite the existing Solr KG if it exists",
),
] = False,
): |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
In
solr_cli.py
:Description
I have a primary CLI file, and a secondary
solr_cli
file with some sub-commands.But when I run any command at all, I get:
This was apparently happening before the release of typer v0.12, when we were using 0.7 with typer-cli separate, but I can't pin down when it started happening or why
Operating System
Linux
Operating System Details
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble
Typer Version
0.12.3
Python Version
3.11.9
Additional Context
Related code with issue can be seen in
cli.py
andsolr_cli.py
of this repositorySome additional notes:
add_typer(solr_cli.solr_app)
I'm able to run the commands defined in the main CLI fileversion
as an argument todownload()
, I instead get:It's possible this issue is with click itself and not typer, but given the first note above, I'm suspicious it has to do with how typer is constructing things to pass to click
Full stack trace:
Beta Was this translation helpful? Give feedback.
All reactions