Я указал две точки входа в своем pyproject.toml
Код: Выделить всё
[tool.poetry.scripts]
mypackage_ep_typer = "my_package.entrypoint_typer:main"
mypackage_ep_argparse = "my_package.entrypoint_argparse:entrypoint_generic"
Код: Выделить всё
def entrypoint_generic():
"""Execute the application."""
logger.info("Executing 'argparse' entrypoint...")
parser = argparse.ArgumentParser(description="My module.")
parser.add_argument(
"--applicationname",
help="The name of the application to execute.",
type=str,
required=True,
dest="applicationname",
)
args = parser.parse_args()
logger.info(f"{args.applicationname=}")
Однако, если я попробую то же самое с typer в enterpoint_typer.py, я не могу заставить его работать:
Код: Выделить всё
def main(
applicationname: Annotated[str, typer.Option(help="Application to execute.")]
):
"""Execute the application."""
logger.info("Executing 'typer' entrypoint...")
logger.info(f"{applicationname=}")
Код: Выделить всё
> poetry run python -m typer .\entrypoint_typer.py run --applicationname MYAPPNAME
2024-11-06 xx:xx:xx - root - INFO - Executing 'typer' entrypoint...
2024-11-06 xx:xx:xx - root - INFO - applicationname='MYAPPNAME'
Код: Выделить всё
TypeError: main() missing 1 required positional argument: 'applicationname'

Подробнее здесь: https://stackoverflow.com/questions/791 ... f-argparse
Мобильная версия