Skip to content

Commit

Permalink
Cleanups to shorten the diff
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Jul 28, 2024
1 parent d2fe36f commit 3d2cdb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/incremental/_hatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 6 additions & 7 deletions src/incremental/tests/test_pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 3d2cdb1

Please sign in to comment.