On Windows only (via GHA): TOML parsing error: "Couldn't read config file pyproject.toml: Unescaped '' in a string" · Issue #1481 · nedbat/coveragepy (original) (raw)
Describe the bug
I have a pyproject.toml which includes an entry:
install = "if [ $VIRTUAL_ENV ]; then pip install -r local-requirements.txt; else printf '%s\n' 'Please activate a venv first'; return 1; fi"
It's in a section unrelated to test running or coverage operations.
This seems fine on Linux and MacOS, but as I add a Windows 2022 runner to the coverage-invoking GitHub Actions workflow, which invokes the nox session:
nox.options.default_venv_backend = 'venv' nox.options.reuse_existing_virtualenvs = True
@nox.session(python=['3.7', '3.8', '3.9', '3.10', '3.11']) def test(session): """Run all tests.""" session.install('.[test,toml]', 'coverage') session.run('coverage', 'run', '-p', '-m', 'ward', *session.posargs)
the following failure is produced:
Run nox -s test test_without_toml combine_coverage --force-color
nox -s test test_without_toml combine_coverage --force-color
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
nox > Running session test-3.7
nox > Creating virtual environment (venv) using python.exe in .nox\test-3-7
nox > python -m pip install '.[test,toml]' coverage
nox > coverage run -p -m ward
Couldn't read config file pyproject.toml: Unescaped '\' in a string (at line 62, column 21)
I've checked the TOML file with https://www.toml-lint.com/ and no problems were reported.
To Reproduce
- Python versions:
3.7.9
,3.8.10
,3.9.13
,3.10.8
coverage==6.5.0
;coverage debug sys
fails withCouldn't read config file pyproject.toml: Unescaped '\' in a string (at line 62, column 21)
- Package versions for the Python 3.7 run:
arrow==1.2.3 attrs==22.1.0 cattrs==22.2.0 click==8.1.3 click-completion==0.5.2 click-default-group==1.2.2 colorama==0.4.6 commonmark==0.9.1 coverage==6.5.0 cucumber-tag-expressions==4.1.0 exceptiongroup==1.0.0rc9 importlib-metadata==5.0.0 inform==1.27.0 Jinja2==3.1.2 MarkupSafe==2.1.1 nestedtext==3.4.0 nt2 @ file:///D:/a/nestedtextto/nestedtextto pluggy==1.0.0 plumbum==1.8.0 pprintpp==0.4.0 Pygments==2.13.0 python-dateutil==2.8.2 pywin32==304 rich==12.6.0 ruamel.yaml==0.17.21 ruamel.yaml.clib==0.2.7 shellingham==1.5.0 six==1.16.0 tomli==2.0.1 tomli-w==1.0.0 typing-extensions==4.4.0 ward==0.66.1b0 yamlpath==3.6.7 zipp==3.10.0
4. This repo at this commit exhibits the problem. At that commit, the problem is encountered before the regular coverage run, at the coverage debug sys
invocation. At the next commit, the same problem is raised at the point of coverage run -p -m ward
.
5. nox -s test
(in a Windows environment) should do the trick.
Expected behavior
The TOML is parsed without issue and tests are run.