Skip to content

avoid private tomlkit method - #5943

Merged
neersighted merged 1 commit into
python-poetry:masterfrom
dimbleby:tomlkit-nonsense
Jul 13, 2022
Merged

neersighted merged 1 commit into
python-poetry:masterfrom
dimbleby:tomlkit-nonsense

Conversation

@dimbleby

@dimbleby dimbleby commented Jul 2, 2022

Copy link
Copy Markdown
Contributor

Fixes #4718

I don't know why the code was using the private method _insert_after(), in only this one place. So far as I can see it's unnecessary; but tomlkit remains quite the mystery to me.

Following the repro of #4718 (comment), we now successfully achieve a pyproject.toml structured as follows:

[tool.poetry]
name = "foo"
and = "so on"

[tool.poetry.dependencies]
python = "^3.10"

[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.plugins]

which has put the new entry in a sensible place anyway, so that's good.

Not sure how to write a test for this or that it's even worthwhile. This branch is covered in existing tests so not breaking them is a strong start, the new code is much more obvious than the old code was, I feel that a new testcase would be testing tomlkit more than it would be testing poetry.

@mkniewallner mkniewallner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not familiar with tomlkit, but this definitely looks ok to me.

Only thing I can see, which I don't think is related to this change but more to how tomlkit works. Given this file:

[tool.poetry]
name = "aaa"
version = "0.1.0"
description = ""
authors = []

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.dependencies]
python = "^3.9"

By running poetry add --group dev pytest, the file will be modified to:

[tool.poetry]
name = "aaa"
version = "0.1.0"
description = ""
authors = []
[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.dependencies]
python = "^3.9"

So there seems to be a mishandling of the carriage return (but again, pretty sure it's not related to the change, just thought it would be worth mentioning).

@dimbleby

dimbleby commented Jul 3, 2022

Copy link
Copy Markdown
Contributor Author

@mkniewallner if you think the missing newline is interesting, please take it to the tomlkit repository

@neersighted
neersighted merged commit 45a1a3b into python-poetry:master Jul 13, 2022
@dimbleby
dimbleby deleted the tomlkit-nonsense branch July 13, 2022 09:06
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError when adding a dependency group when private repo present (Poetry 1.2.0a2)

3 participants