Skip to content

Commit f00ffcb

Browse files
Fix TestAddAuthor.test_append: unwrap tomlkit Array to plain dicts in add_author
The in-place Array modification in extend_list now preserves the tomlkit Array type. The add_author delete/re-set dance needs plain Python dicts to trigger tomlkit's format conversion to [[project.authors]]. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/6a19efab-dd8b-4ba2-ae5e-1f9670293228 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent 7e66ab2 commit f00ffcb

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/usethis/_core/author.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def add_author(
2929

3030
# Moving the authors list to the end of the project table to avoid a bug in tomlkit
3131
# Suspected to be similar to this https://github.com/python-poetry/tomlkit/issues/381
32-
full = PyprojectTOMLManager()[["project", "authors"]]
32+
full_raw = PyprojectTOMLManager()[["project", "authors"]]
33+
assert isinstance(full_raw, list)
34+
full = [dict(item) for item in full_raw]
3335
del PyprojectTOMLManager()[["project", "authors"]]
3436
PyprojectTOMLManager()[["project", "authors"]] = full
3537
else:

tests/usethis/_core/test_author.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def test_append(self, tmp_path: Path):
5858
assert (tmp_path / "pyproject.toml").read_text() == (
5959
"""\
6060
61-
6261
[[project.authors]]
6362
name = "First Contributor"
6463
[[project.authors]]

0 commit comments

Comments
 (0)