pythontyper

Simple typer script gives TypeError


I think typer 0.15.3 (maybe earlier) is broken. I don't make this claim lightly. But if I create a very basic script, I get an error:

pyproject.toml:

[project]
name = "typer-example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "typer>=0.15.3",
]

main.py:

import typer

def main(name: str):
        print(f"Hello, {name}!")

typer.run(main)
❯ uv run python main.py
# ... stack trace
TypeError: TyperArgument.make_metavar() takes 1 positional argument but 2 were given

I expect default help output rather than a TypeError. Am I missing something? Or is typer broken as of 0.15.3?


Solution

  • The Click incompatibility issue as described in https://stackoverflow.com/a/79617479 has been fixed in the v0.16.0 release of Typer.

    TypeError: TyperArgument.make_metavar() takes 1 positional argument but 2 were given
    

    The best current solution is to upgrade/pin Typer to >=0.16.0.