typer icon indicating copy to clipboard operation
typer copied to clipboard

✨ Allow running scripts that import other scripts with `typer` command

Open atomiechen opened this issue 1 year ago • 0 comments

Issue

typer command cannot run a script which imports other scripts in the same directory, or in the subdirectory.

The original problem comes from https://github.com/tiangolo/typer-cli/discussions/142, and I still can reproduce this with typer version 0.12.3.

Changes I Made

  • add sys.path.append(str(state.file.parent)) before exec_module
  • add a test for this

You can check that the test won't pass without the modification of sys.path.

atomiechen avatar Jun 23 '24 06:06 atomiechen