diff --git a/src/incremental/_hatch.py b/src/incremental/_hatch.py index 39ddcb7..b7e5325 100644 --- a/src/incremental/_hatch.py +++ b/src/incremental/_hatch.py @@ -20,9 +20,7 @@ class IncrementalVersionSource(VersionSourceInterface): def get_version_data(self) -> _VersionData: # type: ignore[override] path = os.path.join(self.root, "./pyproject.toml") - # If the Hatch plugin is running at all we've already opted in. config = _load_pyproject_toml(path) - assert config is not None, "Failed to read {}".format(path) return {"version": _existing_version(config.version_path).public()} def set_version(self, version: str, version_data: Dict[Any, Any]) -> None: diff --git a/src/incremental/tests/test_pyproject.py b/src/incremental/tests/test_pyproject.py index d0f1c0b..0d1f021 100644 --- a/src/incremental/tests/test_pyproject.py +++ b/src/incremental/tests/test_pyproject.py @@ -52,9 +52,10 @@ def test_fileNotFound(self): def test_brokenToml(self): """ - Syntactially invalid TOML is ignored unless there's an opt-in. + Syntactially invalid TOML produces an exception. The specific + exception varies by the underlying TOML library. """ - toml = '[project]\nname = "abc' # truncated + toml = '[project]\nname = "abc' # Truncated string. self.assertRaises(Exception, self._loadToml, toml) def test_nameMissing(self): @@ -72,8 +73,7 @@ def test_nameMissing(self): def test_nameInvalidOptIn(self): """ - Once opted in, `TypeError` is raised when the project name - isn't a string. + `TypeError` is raised when the project name isn't a string. """ for toml in [ "[project]\nname = false\n", @@ -85,9 +85,8 @@ def test_nameInvalidOptIn(self): def test_toolIncrementalInvalid(self): """ - When ``[tool]`` or ``[tool.incremental]`` isn't a table the - ``pyproject.toml`` it's an error if opted-in, otherwise the - file is ignored. + `ValueError` is raised when the ``[tool]`` or ``[tool.incremental]`` + isn't a table. """ for toml in [ "tool = false\n",