question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automated migration to groups during `poetry add --group dev`

See original GitHub issue

Running poetry add --group dev (or poetry add --dev) with a dependency that already exists in the [tool.poetry.dev-dependencies] section adds a new entry in [tool.poetry.group.dev.dependencies that may conflict with the existing entry.

It’s easily fixed (updating [tool.poetry.dev-dependencies] to [tool.poetry.group.dev.dependencies], and merging the sections if the extra entry has already been added) but it makes the Poetry 1.1 -> 1.2 upgrade painful if you’ve got lots of repos.

# syntax=docker/dockerfile:1.3-labs
FROM python:3.8
RUN pip install poetry==1.2.1
WORKDIR /src
COPY <<"EOF" pyproject.toml
[tool.poetry]
name = ""
version = "0.1.0"
description = ""
authors = [""]

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

[tool.poetry.dev-dependencies]
tomli = "1.0.0"

EOF

# Using `poetry add --group dev` and `poetry add --dev` produce the same result.
RUN poetry add --group dev tomli@2.0.0
RUN cat pyproject.toml && poetry lock

produces

 > [6/6] RUN cat pyproject.toml && poetry lock:
#14 0.534 [tool.poetry]
#14 0.534 name = ""
#14 0.534 version = "0.1.0"
#14 0.534 description = ""
#14 0.534 authors = [""]
#14 0.534
#14 0.534 [tool.poetry.dependencies]
#14 0.534 python = "^3.8"
#14 0.534
#14 0.534 [tool.poetry.dev-dependencies]
#14 0.534 tomli = "1.0.0"
#14 0.534
#14 0.534 [[tool.poetry.source]]
#14 0.534 name = 'simple'
#14 0.534 url = 'https://pypi.org/simple'
#14 0.534 default = true
#14 0.534
#14 0.534
#14 0.534 [tool.poetry.group.dev.dependencies]
#14 0.534 tomli = "2.0.0"
#14 0.534
#14 1.122 Updating dependencies
#14 1.123 Resolving dependencies...
#14 1.133
#14 1.133 Because  depends on both tomli (2.0.0) and tomli (1.0.0), version solving failed.

edit: Removed unnecessary [tool.poetry.source] section in Dockerfile.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
neersightedcommented, Oct 2, 2022

I assume that’s add -G dev? I think that’s up to us to decide – my immediate thoughts are we could do a wholesale migration the first time -G dev is used. That is to say, migrate everything from dev-dependencies to groups.dev, write pyproject.toml, and then do the add as normal.

Yes, this forces migration for users who are using -G dev on the command line, but we already effectively do that – this just removes the split brain situation.

1reaction
neersightedcommented, Oct 1, 2022

dev-dependencies is implicitly used/combined right now – I don’t think we can walk back from that behavior immediately – warning and removing it in a future version is better, I think.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing Poetry 1.2.0 | Blog
As the dev-dependencies is now deprecated, projects should migrate to the new group syntax as soon as possible. Keep in mind that the...
Read more >
poetry-dynamic-versioning - PyPI
Dynamic versioning plugin for Poetry. This is a Python 3.7+ plugin for Poetry 1.2.0+ and Poetry Core 1.0.0+ to enable dynamic versioning based...
Read more >
How to auto create Groups in Django 1.11.2 - Stack Overflow
I assume, that your new Group must have all the permissions. Your query is wronge: add_thing = Permission.objects.get( ...
Read more >
Migrating a project to Poetry - browniebroke.com
Adding dependencies and development dependencies was pretty simple, I just needed to run poetry add [-D] ... with the list of packages at...
Read more >
congregate/main.py · master · GitLab.org / Professional ...
GitLab Professional Services migration utility Congregate is an automation wrapper around the GitLab APIs, in particular the export/import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found