# Buggy code
def _expand_non_flag(
    self, at: int, ini_dir: Path, line: str, result: List[str]
) -> None:  # noqa
    try:
        req = Requirement(line)
    except InvalidRequirement as exc:
        if is_url(line) or any(
            line.startswith(f"{v}+") and is_url(line[len(v) + 1 :]) for v in VCS
        ):
            result.append(line)
        else:
            path = ini_dir / line
            try:
                is_valid_file = path.exists() and (path.is_file() or path.is_dir())
            except OSError:  # https://bugs.python.org/issue42855 # pragma: no cover
                is_valid_file = False  # pragma: no cover
            if not is_valid_file:
                raise ValueError(f"{at}: {line}") from exc
            result.append(str(path))
    else:
        result.append(str(req))


# Traceback (ValueError)
$ python -m tox -rvv -e py39
ROOT: 255 D setup logging to DEBUG on pid 45306 [tox/report.py:211]
ROOT: 261 W remove tox env folder /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39 [tox/tox_env/api.py:190]
ROOT: 334 I find interpreter for spec PythonSpec(implementation=CPython, major=3, minor=9) [virtualenv/discovery/builtin.py:62]
ROOT: 334 I proposed PythonInfo(spec=CPython3.9.1.final.0-64, exe=/Users/chainz/.pyenv/versions/3.9.1/bin/python, platform=darwin, version='3.9.1 (default, Jan 21 2021, 09:04:53) \n[Clang 12.0.0 (clang-1200.0.32.28)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:69]
ROOT: 334 D accepted PythonInfo(spec=CPython3.9.1.final.0-64, exe=/Users/chainz/.pyenv/versions/3.9.1/bin/python, platform=darwin, version='3.9.1 (default, Jan 21 2021, 09:04:53) \n[Clang 12.0.0 (clang-1200.0.32.28)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:71]
ROOT: 336 D filesystem is not case-sensitive [virtualenv/info.py:28]
ROOT: 388 I create virtual environment via CPython3Posix(dest=/Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39, clear=True, no_vcs_ignore=False, global=False) [virtualenv/run/session.py:52]
ROOT: 388 D delete /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39 [virtualenv/create/creator.py:169]
ROOT: 388 D create folder /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin [virtualenv/util/path/_sync.py:25]
ROOT: 389 D create folder /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages [virtualenv/util/path/_sync.py:25]
ROOT: 389 D write /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:34]
ROOT: 389 D     home = /Users/chainz/.pyenv/versions/3.9.1 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     implementation = CPython [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     version_info = 3.9.1.final.0 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     virtualenv = 20.4.2 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     base-prefix = /Users/chainz/.pyenv/versions/3.9.1 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     base-exec-prefix = /Users/chainz/.pyenv/versions/3.9.1 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 389 D     base-executable = /Users/chainz/.pyenv/versions/3.9.1/bin/python [virtualenv/create/pyenv_cfg.py:38]
ROOT: 390 D symlink /Users/chainz/.pyenv/versions/3.9.1/bin/python to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/python [virtualenv/util/path/_sync.py:44]
ROOT: 390 D create virtualenv import hook file /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/_virtualenv.pth [virtualenv/create/via_global_ref/api.py:95]
ROOT: 391 D create /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/_virtualenv.py [virtualenv/create/via_global_ref/api.py:98]
ROOT: 391 D ============================== target debug ============================== [virtualenv/run/session.py:54]
ROOT: 392 D debug via /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/python /Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/virtualenv/create/debug.py [virtualenv/create/creator.py:224]
ROOT: 392 D {
"sys": {
"executable": "/Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/python",
"_base_executable": "/Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/python",
"prefix": "/Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39",
"base_prefix": "/Users/chainz/.pyenv/versions/3.9.1",
"real_prefix": null,
"exec_prefix": "/Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39",
"base_exec_prefix": "/Users/chainz/.pyenv/versions/3.9.1",
"path": [
"/Users/chainz/.pyenv/versions/3.9.1/lib/python39.zip",
"/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9",
"/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/lib-dynload",
"/Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages"
],
"meta_path": [
"<class '_virtualenv._Finder'>",
"<class '_frozen_importlib.BuiltinImporter'>",
"<class '_frozen_importlib.FrozenImporter'>",
"<class '_frozen_importlib_external.PathFinder'>"
],
"fs_encoding": "utf-8",
"io_encoding": "utf-8"
},
"version": "3.9.1 (default, Jan 21 2021, 09:04:53) \n[Clang 12.0.0 (clang-1200.0.32.28)]",
"makefile_filename": "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/config-3.9-darwin/Makefile",
"os": "<module 'os' from '/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/os.py'>",
"site": "<module 'site' from '/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site.py'>",
"datetime": "<module 'datetime' from '/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/datetime.py'>",
"math": "<module 'math' from '/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/lib-dynload/math.cpython-39-darwin.so'>",
"json": "<module 'json' from '/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/json/__init__.py'>"
} [virtualenv/run/session.py:55]
ROOT: 463 I add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/chainz/Library/Application Support/virtualenv) [virtualenv/run/session.py:59]
py39: 468 D got embed update of distribution pip from /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/embed/1/pip.json [virtualenv/app_data/via_disk_folder.py:135]
py39: 468 D got embed update of distribution setuptools from /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/embed/1/setuptools.json [virtualenv/app_data/via_disk_folder.py:135]
py39: 471 D got embed update of distribution wheel from /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/embed/1/wheel.json [virtualenv/app_data/via_disk_folder.py:135]
py39: 471 D using periodically updated wheel /Users/chainz/Library/Application Support/virtualenv/wheel/house/pip-20.3.3-py2.py3-none-any.whl [virtualenv/seed/wheels/periodic_update.py:53]
py39: 472 D using periodically updated wheel /Users/chainz/Library/Application Support/virtualenv/wheel/house/setuptools-51.1.2-py3-none-any.whl [virtualenv/seed/wheels/periodic_update.py:53]
py39: 472 D install wheel from wheel /Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/virtualenv/seed/wheels/embed/wheel-0.36.2-py2.py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:49]
py39: 473 D install pip from wheel /Users/chainz/Library/Application Support/virtualenv/wheel/house/pip-20.3.3-py2.py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:49]
py39: 473 D install setuptools from wheel /Users/chainz/Library/Application Support/virtualenv/wheel/house/setuptools-51.1.2-py3-none-any.whl via CopyPipInstall [virtualenv/seed/embed/via_app_data/via_app_data.py:49]
py39: 474 D Attempting to acquire lock 4495476432 on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any.lock [filelock.py:270]
py39: 474 D Attempting to acquire lock 4495476336 on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any.lock [filelock.py:270]
py39: 474 D Lock 4495476432 acquired on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any.lock [filelock.py:274]
py39: 474 D Lock 4495476336 acquired on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any.lock [filelock.py:274]
py39: 474 D Attempting to acquire lock 4495476480 on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any.lock [filelock.py:270]
py39: 475 D Attempting to release lock 4495476432 on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any.lock [filelock.py:315]
py39: 475 D Attempting to release lock 4495476336 on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any.lock [filelock.py:315]
py39: 475 D Lock 4495476480 acquired on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any.lock [filelock.py:274]
py39: 475 D Lock 4495476432 released on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any.lock [filelock.py:318]
py39: 475 D Lock 4495476336 released on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any.lock [filelock.py:318]
py39: 475 D Attempting to release lock 4495476480 on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any.lock [filelock.py:315]
py39: 476 D Lock 4495476480 released on /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any.lock [filelock.py:318]
py39: 476 D copy /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any/pip-20.3.3.virtualenv to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/pip-20.3.3.virtualenv [virtualenv/util/path/_sync.py:52]
py39: 476 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any/wheel-0.36.2.dist-info to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/wheel-0.36.2.dist-info [virtualenv/util/path/_sync.py:52]
py39: 476 D copy /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/setuptools-51.1.2.virtualenv to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/setuptools-51.1.2.virtualenv [virtualenv/util/path/_sync.py:52]
py39: 477 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any/pip to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/pip [virtualenv/util/path/_sync.py:52]
py39: 477 D copy /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/easy_install.py to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/easy_install.py [virtualenv/util/path/_sync.py:52]
py39: 479 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/setuptools-51.1.2.dist-info to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/setuptools-51.1.2.dist-info [virtualenv/util/path/_sync.py:52]
py39: 484 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any/wheel to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/wheel [virtualenv/util/path/_sync.py:52]
py39: 488 D copy /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/distutils-precedence.pth to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/distutils-precedence.pth [virtualenv/util/path/_sync.py:52]
py39: 489 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/setuptools to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/setuptools [virtualenv/util/path/_sync.py:52]
py39: 503 D copy /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/wheel-0.36.2-py2.py3-none-any/wheel-0.36.2.virtualenv to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/wheel-0.36.2.virtualenv [virtualenv/util/path/_sync.py:52]
py39: 508 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/wheel3.9 to 755 [distlib/util.py:566]
py39: 509 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/wheel-3.9 to 755 [distlib/util.py:566]
py39: 511 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/wheel to 755 [distlib/util.py:566]
py39: 512 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/wheel3 to 755 [distlib/util.py:566]
py39: 512 D generated console scripts wheel3.9 wheel-3.9 wheel wheel3 [virtualenv/seed/embed/via_app_data/pip_install/base.py:48]
py39: 615 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/pkg_resources to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/pkg_resources [virtualenv/util/path/_sync.py:52]
py39: 626 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/setuptools-51.1.2-py3-none-any/_distutils_hack to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/_distutils_hack [virtualenv/util/path/_sync.py:52]
py39: 628 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/easy_install-3.9 to 755 [distlib/util.py:566]
py39: 629 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/easy_install to 755 [distlib/util.py:566]
py39: 629 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/easy_install3.9 to 755 [distlib/util.py:566]
py39: 629 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/easy_install3 to 755 [distlib/util.py:566]
py39: 629 D generated console scripts easy_install easy_install-3.9 easy_install3 easy_install3.9 [virtualenv/seed/embed/via_app_data/pip_install/base.py:48]
py39: 767 D copy directory /Users/chainz/Library/Application Support/virtualenv/wheel/3.9/image/1/CopyPipInstall/pip-20.3.3-py2.py3-none-any/pip-20.3.3.dist-info to /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/lib/python3.9/site-packages/pip-20.3.3.dist-info [virtualenv/util/path/_sync.py:52]
py39: 771 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/pip3 to 755 [distlib/util.py:566]
py39: 771 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/pip to 755 [distlib/util.py:566]
py39: 772 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/pip3.9 to 755 [distlib/util.py:566]
py39: 772 D changing mode of /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/bin/pip-3.9 to 755 [distlib/util.py:566]
py39: 772 D generated console scripts pip3.9 pip3 pip-3.9 pip [virtualenv/seed/embed/via_app_data/pip_install/base.py:48]
ROOT: 772 I add activators for Bash, CShell, Fish, PowerShell, Python, Xonsh [virtualenv/run/session.py:64]
ROOT: 775 D write /Users/chainz/Documents/Projects/apig-wsgi/.tox/4/py39/pyvenv.cfg [virtualenv/create/pyenv_cfg.py:34]
ROOT: 775 D     home = /Users/chainz/.pyenv/versions/3.9.1 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 775 D     implementation = CPython [virtualenv/create/pyenv_cfg.py:38]
ROOT: 775 D     version_info = 3.9.1.final.0 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 775 D     virtualenv = 20.4.2 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 775 D     include-system-site-packages = false [virtualenv/create/pyenv_cfg.py:38]
ROOT: 775 D     base-prefix = /Users/chainz/.pyenv/versions/3.9.1 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 775 D     base-exec-prefix = /Users/chainz/.pyenv/versions/3.9.1 [virtualenv/create/pyenv_cfg.py:38]
ROOT: 809 D     base-executable = /Users/chainz/.pyenv/versions/3.9.1/bin/python [virtualenv/create/pyenv_cfg.py:38]
ROOT: 813 E internal error [tox/session/cmd/run/single.py:53]
Traceback (most recent call last):
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/packaging/requirements.py", line 104, in __init__
req = REQUIREMENT.parseString(requirement_string)
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString
raise exc
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pyparsing.py", line 3814, in parseImpl
raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected stringEnd, found '-'  (at char 18), (line:1, col:19)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/req_file.py", line 120, in _expand_non_flag
req = Requirement(line)
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/packaging/requirements.py", line 106, in __init__
raise InvalidRequirement(
packaging.requirements.InvalidRequirement: Parse error at "'--hash=s'": Expected stringEnd

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/session/cmd/run/single.py", line 41, in _evaluate
tox_env.ensure_setup(recreate=recreate)
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/api.py", line 167, in ensure_setup
self.setup()
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/virtual_env/api.py", line 67, in setup
super().setup()
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/runner.py", line 48, in setup
self.install_deps()
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/runner.py", line 72, in install_deps
requirement_file_content = requirements_file.validate_and_expand()
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/req_file.py", line 113, in validate_and_expand
self._expand_flag(ini_dir, line, result)
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/req_file.py", line 157, in _expand_flag
result.extend(req_file.validate_and_expand())
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/req_file.py", line 115, in validate_and_expand
self._expand_non_flag(at, ini_dir, line, result)
File "/Users/chainz/.pyenv/versions/3.9.1/lib/python3.9/site-packages/tox/tox_env/python/req_file.py", line 131, in _expand_non_flag
raise ValueError(f"{at}: {line}") from exc
ValueError: 7: attrs==20.3.0     --hash=sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6     --hash=sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700
py39: FAIL ✖ in 0.58 seconds
py39: FAIL code 2 (0.58 seconds)
evaluation failed :( (0.64 seconds)

# Fixed code
def _expand_non_flag(
    self, at: int, ini_dir: Path, line: str, result: List[str]
) -> None:  # noqa
    try:
        at = line.index(" --hash")
        requirement, hash_part = line[:at], re.sub(r"\s+", " ", line[at + 1 :])
    except ValueError:
        requirement, hash_part = line, ""
    try:
        req = Requirement(requirement)
    except InvalidRequirement as exc:
        if is_url(line) or any(
            line.startswith(f"{v}+") and is_url(line[len(v) + 1 :]) for v in VCS
        ):
            result.append(line)
        else:
            path = ini_dir / line
            try:
                is_valid_file = path.exists() and (path.is_file() or path.is_dir())
            except OSError:  # https://bugs.python.org/issue42855 # pragma: no cover
                is_valid_file = False  # pragma: no cover
            if not is_valid_file:
                raise ValueError(f"{at}: {line}") from exc
            result.append(str(path))
    else:
        entry = str(req)
        if hash_part:
            entry = f"{entry} {hash_part}"
        result.append(entry)