Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage cannot parse valid pyproject.toml file #1169

Closed
SeanDS opened this issue Jun 2, 2021 · 6 comments
Closed

Coverage cannot parse valid pyproject.toml file #1169

SeanDS opened this issue Jun 2, 2021 · 6 comments

Comments

@SeanDS
Copy link

SeanDS commented Jun 2, 2021

Describe the bug
Coverage.py, installed with the [toml] extra, seems to have trouble parsing this valid pyproject.toml file for a project called finesse:

[build-system]
requires = [
    "setuptools",
    "wheel",
    "setuptools_scm[toml]",
    "Cython",
    "numpy == 1.20.3",  # Should match that in setup.cfg install_requires.
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/finesse/version.py"

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.doc8]
max-line-length = 88

[tool.coverage.run]
plugins = "Cython.Coverage"

When I run coverage with pytest --cov=finesse --cov-config=pyproject.toml --cov-report=xml tests, I get this error:

   raise CoverageException("Couldn't read config file %s: %s" % (filename, err))
coverage.misc.CoverageException: Couldn't read config file pyproject.toml: Source contains parsing errors: 'pyproject.toml'
	[line  8]: ']\n'

Narrowing it down, I can see the problem is HandyConfigParser:

>>> import coverage
>>> x = coverage.config.HandyConfigParser(False)
>>> x.read("pyproject.toml")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/envs/finesse3/lib/python3.9/site-packages/coverage/config.py", line 38, in read
    return configparser.RawConfigParser.read(self, filenames, **kwargs)
  File "/envs/finesse3/lib/python3.9/configparser.py", line 697, in read
    self._read(fp, filename)
  File "/envs/finesse3/lib/python3.9/configparser.py", line 1113, in _read
    raise e
configparser.ParsingError: Source contains parsing errors: 'pyproject.toml'
        [line  8]: ']\n'

This linting tool reports the file is valid. In TOML it is acceptable to have arrays spanning multiple lines, trailing commas and inline comments.

To Reproduce

  1. What version of Python are you using? 3.9.5

  2. What version of coverage.py are you using? The output of coverage debug sys is helpful.

-- sys -------------------------------------------------------
              version: 4.5.4
             coverage: /envs/finesse3/lib/python3.9/site-packages/coverage/__init__.py
          cover_paths: /envs/finesse3/lib/python3.9/site-packages/coverage
          pylib_paths: /envs/finesse3/lib/python3.9
               tracer: CTracer
 plugins.file_tracers: -none-
  plugins.configurers: -none-
         config_files: .coveragerc
                       setup.cfg
                       tox.ini
         configs_read: setup.cfg
            data_path: /home/sean/Workspace/Repositories/finesse3/.coverage
               python: 3.9.5 (default, May 18 2021, 19:34:48) [GCC 7.3.0]
             platform: Linux-5.12.7-arch1-1-x86_64-with-glibc2.33
       implementation: CPython
           executable: /envs/finesse3/bin/python
                  cwd: /home/sean/Workspace/Repositories/finesse3
                 path: 
                       /envs/finesse3/lib/python39.zip
                       /envs/finesse3/lib/python3.9
                       /envs/finesse3/lib/python3.9/lib-dynload
                       /home/sean/.local/lib/python3.9/site-packages
                       /home/sean/Workspace/Repositories/zero
                       /home/sean/Workspace/Repositories/pt-noise-budget
                       /home/sean/Workspace/Repositories/pinto
                       /envs/finesse3/lib/python3.9/site-packages
                       /home/sean/Workspace/Repositories/finesse3/src
          environment: -none-
         command_line: /envs/finesse3/bin/coverage debug sys
         source_match: -none-
    source_pkgs_match: -none-
        include_match: -none-
           omit_match: -none-
          cover_match: /envs/finesse3/lib/python3.9/site-packages/coverage
          pylib_match: /envs/finesse3/lib/python3.9
  1. What versions of what packages do you have installed? The output of pip freeze is helpful.
alabaster==0.7.12
appdirs==1.4.4
argon2-cffi==20.1.0
arviz==0.11.2
astroid==2.5.6
async-generator==1.10
attrs==21.2.0
Babel==2.9.0
backcall==0.2.0
bandit==1.7.0
beancount==2.3.4
beautifulsoup4==4.9.3
black==21.5b2
bleach==3.3.0
blessed==1.17.12
blinker==1.4
bottle==0.12.19
cachetools==4.2.1
cdsutils==1.4.2
certifi==2021.5.30
cffi==1.14.5
cfgv==3.3.0
cftime==1.4.1
chardet==4.0.0
cheroot==8.5.2
click==8.0.1
click-default-group==1.2.2
control==0.9.0
coverage==4.5.4
cycler==0.10.0
dateparser==1.0.0
decorator==4.4.2
defusedxml==0.7.1
dill==0.3.3
distlib==0.3.2
doc8==0.8.1
docutils==0.16
entrypoints==0.3
extruct==0.12.0
ezca==1.4.0
Faker==8.4.0
fastprogress==1.0.0
fava==1.18
feedgenerator==1.9.1
filelock==3.0.12
flake8==3.9.2
flake8-bugbear==21.4.3
Flask==1.1.2
Flask-Babel==2.0.0
fuzzywuzzy==0.18.0
gitdb==4.0.7
GitPython==3.1.14
google-api-core==1.26.3
google-api-python-client==2.2.0
google-auth==1.29.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.53.0
gpstime==0.3.3
graphviz==0.16
guardian==1.4.4
gwinc==0.2.2
h5py==3.2.1
html-text==0.5.2
httplib2==0.19.1
humanize==3.4.1
hypothesis==6.13.11
hypothesmith==0.1.8
identify==2.2.7
idna==2.10
imagesize==1.2.0
iniconfig==1.1.1
ipykernel==5.5.5
ipython==7.21.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
isodate==0.6.0
isort==5.8.0
itsdangerous==1.1.0
jaraco.functools==3.3.0
jedi==0.18.0
Jinja2==3.0.1
jsonschema==3.2.0
jstyleson==0.0.2
jupyter-client==6.1.12
jupyter-core==4.7.1
jupyter-sphinx==0.3.2
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
kiwisolver==1.3.1
langdetect==1.0.8
lark-parser==0.11.2
latexcodec==2.0.1
lazy-object-proxy==1.6.0
libcst==0.3.17
livereload==2.6.3
lxml==4.6.3
markdown2==2.4.0
MarkupSafe==2.0.1
matplotlib==3.4.2
maya==0.6.1
mccabe==0.6.1
mf2py==1.1.2
mistune==0.8.4
more-itertools==8.7.0
mpmath==1.2.1
mypy-extensions==0.4.3
nbclient==0.5.3
nbconvert==6.0.7
nbformat==5.1.2
nbsphinx==0.8.2
nest-asyncio==1.5.1
netCDF4==1.5.6
networkx==2.5.1
nodeenv==1.6.0
notebook==6.4.0
numpy==1.20.3
numpydoc==1.1.0
packaging==20.9
pandas==1.2.4
pandocfilters==1.4.3
parso==0.8.1
pathspec==0.8.1
patsy==0.5.1
pbr==5.5.1
pelican==4.5.4
pendulum==2.1.2
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.1.0
pluggy==0.13.1
pre-commit==2.13.0
progressbar2==3.53.1
prometheus-client==0.11.0
prompt-toolkit==3.0.17
protobuf==3.15.8
ptyprocess==0.7.0
py==1.10.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pybtex==0.24.0
pybtex-docutils==1.0.0
pycairo==1.20.0
pycobertura==2.0.1
pycodestyle==2.7.0
pycparser==2.20
pydot==1.4.2
pyepics==3.4.3
pyflakes==2.3.1
Pygments==2.6.1
pylint==2.8.3
pymc3==3.11.2
pyparsing==2.4.7
pyRdfa3==3.5.3
pyrsistent==0.17.3
pytest==6.2.4
pytest-cov==2.10.1
python-dateutil==2.8.1
python-Levenshtein==0.12.2
python-magic==0.4.22
python-utils==2.5.6
pytz==2021.1
pytzdata==2020.1
PyYAML==5.4.1
pyzmq==22.0.3
quantiphy==2.13.0
rdflib==5.0.0
rdflib-jsonld==0.5.0
recipe-scrapers==13.2.3
regex==2020.11.13
requests==2.25.1
reslate==0.56.0
restructuredtext-lint==1.3.2
rsa==4.7.2
scipy==1.6.3
semver==2.13.0
Send2Trash==1.5.0
setuptools-scm==6.0.1
simplejson==3.17.2
six==1.16.0
sly==0.4
smmap==4.0.0
snaptime==0.2.4
snowballstemmer==2.1.0
social-analyzer==0.8
sortedcontainers==2.3.0
soupsieve==2.2
Sphinx==4.0.2
sphinx-autobuild==2021.3.14
sphinx-rtd-theme==0.5.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-bibtex==2.3.0
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-katex==0.8.6
sphinxcontrib-programoutput==0.17
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
sphinxcontrib-svg2pdfconverter==1.1.1
stevedore==3.3.0
sympy==1.8
tabulate==0.8.9
termcolor==1.1.0
terminado==0.10.0
testpath==0.4.4
text-unidecode==1.3
Theano-PyMC==1.1.2
tld==0.12.5
toml==0.10.2
tornado==6.1
traitlets==5.0.5
typing-extensions==3.7.4.3
typing-inspect==0.6.0
tzlocal==2.1
Unidecode==1.1.2
uritemplate==3.0.1
urllib3==1.26.5
virtualenv==20.4.7
w3lib==1.22.0
wcwidth==0.2.5
webencodings==0.5.1
Werkzeug==1.0.1
widgetsnbextension==3.5.1
wrapt==1.12.1
xarray==0.17.0
  1. What code are you running? Give us a specific commit of a specific repo that we can check out.

Can provide if required. I am not sure this is helpful and will be a lot of work for readers to install.

  1. What commands did you run?

See bug description.

Expected behavior
coverage.py parses the above pyproject.toml file without errors.

@SeanDS SeanDS added the bug Something isn't working label Jun 2, 2021
@nedbat
Copy link
Owner

nedbat commented Jun 2, 2021

From the "debug sys" output, it looks like you have coverage.py version 4.5.4, which didn't support TOML. If you install the latest version (5.5), you should be fine.

@nedbat nedbat added invalid and removed bug Something isn't working labels Jun 2, 2021
@nedbat nedbat closed this as completed Jun 2, 2021
@SeanDS
Copy link
Author

SeanDS commented Jun 2, 2021

Ah, that would do it! Sorry for the noise. We are stuck on 4.5 because of this Cython bug blocking us upgrading to 5.

@nedbat
Copy link
Owner

nedbat commented Jun 2, 2021

Oh, I didn't realize there was a Cython plugin (or maybe I forgot?) We should get that fixed.

@cjdsellers
Copy link

cjdsellers commented Jul 23, 2021

Hi Ned, this would be very much appreciated. We're also pinned on coverage 4.5.4 due that Cython issue #3515.

https://github.com/nautechsystems/nautilus_trader/blob/master/pyproject.toml line 66ish.

@nedbat
Copy link
Owner

nedbat commented Jul 24, 2021

I'm not sure what I can do to get the Cython plugin fixed.

@cjdsellers
Copy link

Yes, this is probably something to be addressed by Cython.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants