Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid private tomlkit method #5943

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

dimbleby
Copy link
Contributor

@dimbleby dimbleby commented Jul 2, 2022

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.

Copy link
Member

@mkniewallner mkniewallner left a comment

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
Copy link
Contributor Author

dimbleby commented Jul 3, 2022

@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
Copy link

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