Код: Выделить всё
from pathlib import Path
import typer
def exists(
file: Path = typer.Option(
default="./README.md",
prompt="Enter the file path",
exists=True,
)
):
print(f'The file "{file}" exists')
typer.run(exists)
Код: Выделить всё
from pathlib import Path
from typing_extensions import Annotated
import typer
def exists(
file: Annotated[Path, typer.Option(
default="./README.md",
prompt="Enter the file path",
exists=True,
)]
):
print(f'The file "{file}" exists')
typer.run(exists)
Код: Выделить всё
╭───────────────────────── Traceback (most recent call last) ──────────────────────────╮
│ /.venv/lib/python3.12/site-packages/click/core.py:2852 │
│ in __init__ │
╰──────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Secondary flag is not valid for non-boolean flag.
Подробнее здесь: https://stackoverflow.com/questions/798 ... n-in-typer
Мобильная версия