# Buggy code
def _add_run(subparsers):
    p = subparsers.add_parser(
        "run",
        formatter_class=LineWrapRawTextHelpFormatter,
        help=(
            "Download the latest version of a package to a temporary virtual environment, "
            "then run an app from it. Also compatible with local `__pypackages__` "
            "directory (experimental)."
        ),
        description=textwrap.dedent(
            f"""
        Download the latest version of a package to a temporary virtual environment,
        then run an app from it. The environment will be cached
        and re-used for up to {constants.TEMP_VENV_EXPIRATION_THRESHOLD_DAYS} days. This
        means subsequent calls to 'run' for the same package will be faster
        since they can re-use the cached Virtual Environment.

        In support of PEP 582 'run' will use apps found in a local __pypackages__
         directory, if present. Please note that this behavior is experimental,
         and is a acts as a companion tool to pythonloc. It may be modified or
         removed in the future. See https://github.com/cs01/pythonloc.
        """
        ),
    )
    p.add_argument(
        "--no-cache",
        action="store_true",
        help="Do not re-use cached virtual environment if it exists",
    )
    p.add_argument("app", help="app/package name")
    p.add_argument(
        "appargs",
        nargs=argparse.REMAINDER,
        help="arguments passed to the application when it is invoked",
        default=[],
    )
    p.add_argument(
        "--pypackages",
        action="store_true",
        help="Require app to be run from local __pypackages__ directory",
    )
    p.add_argument("--spec", help=SPEC_HELP)
    p.add_argument("--verbose", action="store_true")
    p.add_argument(
        "--python",
        default=constants.DEFAULT_PYTHON,
        help="The Python version to run package's CLI app with. Must be v3.3+.",
    )
    add_pip_venv_args(p)


# Traceback (SyntaxError)
$ python3.7 -m pip install --user pipx
$ python3.7 -m pipx run  --python python3.4 cowsay 'Hello, world!'
_____________
< Hello, world! >
=============
\
\
^__^
(oo)\_______
(__)\       )\/\
||----w |
||     ||


$  python3.7 -m pipx install --python python3.4 cowsay
File "<string>", line 89
app_paths_of_dependencies: Dict[str, List[str]] = {}
^
SyntaxError: invalid syntax

⢿ installing package 'cowsay'Traceback (most recent call last):
File "/home/bkboulton/.pyenv/versions/py37/bin/pipx", line 10, in <module>
sys.exit(cli())
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/main.py", line 547, in c
exit(run_pipx_command(parsed_pipx_args))
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/main.py", line 166, in r
include_dependencies=args.include_deps,
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/commands.py", line 318,
if venv.get_venv_metadata_for_package(package).package_version is None:
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/Venv.py", line 161, in g
self.python_path, VENV_METADATA_INSPECTOR, package, str(self.bin_path)
File "/home/bkboulton/.pyenv/versions/3.7.4/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/home/bkboulton/.pyenv/versions/3.7.4/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/bkboulton/.pyenv/versions/3.7.4/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

# Fixed code
def _add_run(subparsers):
    p = subparsers.add_parser(
        "run",
        formatter_class=LineWrapRawTextHelpFormatter,
        help=(
            "Download the latest version of a package to a temporary virtual environment, "
            "then run an app from it. Also compatible with local `__pypackages__` "
            "directory (experimental)."
        ),
        description=textwrap.dedent(
            f"""
        Download the latest version of a package to a temporary virtual environment,
        then run an app from it. The environment will be cached
        and re-used for up to {constants.TEMP_VENV_EXPIRATION_THRESHOLD_DAYS} days. This
        means subsequent calls to 'run' for the same package will be faster
        since they can re-use the cached Virtual Environment.

        In support of PEP 582 'run' will use apps found in a local __pypackages__
         directory, if present. Please note that this behavior is experimental,
         and is a acts as a companion tool to pythonloc. It may be modified or
         removed in the future. See https://github.com/cs01/pythonloc.
        """
        ),
    )
    p.add_argument(
        "--no-cache",
        action="store_true",
        help="Do not re-use cached virtual environment if it exists",
    )
    p.add_argument("app", help="app/package name")
    p.add_argument(
        "appargs",
        nargs=argparse.REMAINDER,
        help="arguments passed to the application when it is invoked",
        default=[],
    )
    p.add_argument(
        "--pypackages",
        action="store_true",
        help="Require app to be run from local __pypackages__ directory",
    )
    p.add_argument("--spec", help=SPEC_HELP)
    p.add_argument("--verbose", action="store_true")
    p.add_argument(
        "--python",
        default=constants.DEFAULT_PYTHON,
        help="The Python version to run package's CLI app with. Must be v3.5+.",
    )
    add_pip_venv_args(p)