coveralls-python icon indicating copy to clipboard operation
coveralls-python copied to clipboard

Support pyproject.toml (for coverage package configs) file

Open thombashi opened this issue 2 years ago • 1 comments

I encountered the following error when I run coveralls with coverage settings written in a pyproject.toml file. This PR aims to fix the problem.

Submitting coverage to coveralls.io...
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/coveralls", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coveralls/cli.py", line 95, in main
    result = coverallz.wear()
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coveralls/api.py", line 252, in wear
    json_string = self.create_report()
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coveralls/api.py", line 330, in create_report
    data = self.create_data()
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coveralls/api.py", line 384, in create_data
    self._data = {'source_files': self.get_coverage()}
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coveralls/api.py", line 398, in get_coverage
    workman = coverage.coverage(config_file=config_file)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coverage/control.py", line 239, in __init__
    self.config = read_coverage_config(
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coverage/config.py", line 545, in read_coverage_config
    config_read = config.from_file(fname, warn, our_file=our_file)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coverage/config.py", line 273, in from_file
    files_read = cp.read(filename)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/coverage/tomlconfig.py", line 60, in read
    raise CoverageException(msg.format(filename))
coverage.exceptions.CoverageException: Can't read 'pyproject.toml' without TOML support. Install with [toml] extra

As the error message indicated, coverage is required to install with [toml] extra when you use pyproject.toml as a config file.


note: toml config file support was added at coverage v5.

thombashi avatar Nov 06 '21 15:11 thombashi

Hi @thombashi! I would rather not drop support for coverage v4.x unnecessarily, as many users report using this project with older versions of Python and all the dependencies.

That said, definitely agree that this could be made more clear to users! I would happily accept a PR aimed more at making it clear to users that adding coverage[toml] to their own dev dependencies would allow them to support pyproject.toml files!

TheKevJames avatar Jun 06 '22 14:06 TheKevJames