bagel897 / pytoolconfig

Python tool configuration
GNU Lesser General Public License v3.0
4 stars 2 forks source link

Reachable assertion in PyProject.parse() #5

Closed jwilk closed 2 years ago

jwilk commented 2 years ago

You get an AssertionError when your pyproject.toml is empty.

Reproducer:

import pathlib
import tempfile
from pytoolconfig.sources.pyproject import PyProject

with tempfile.TemporaryDirectory() as tmpdir:
    ptmpdir = pathlib.Path(tmpdir)
    with open(ptmpdir / 'pyproject.toml', 'w'):
        pass
    proj = PyProject(ptmpdir, "eggs")
    proj.parse()

Traceback:

Traceback (most recent call last):
  File "test-pytooltoconfig.py", line 10, in <module>
    proj.parse()
  File ".../site-packages/pytoolconfig/sources/pyproject.py", line 69, in parse
    if not self._read():
  File ".../site-packages/pytoolconfig/sources/pyproject.py", line 62, in _read
    assert self.toml_dict
AssertionError

(I don't have any practical use cases for empty pyproject.toml. I ran into this only when working on the reproducer for #4.)