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

Can add a new dev dependency - Key "dev-dependencies" already exists #3103

Closed
cda2024 opened this issue Aug 13, 2024 · 4 comments
Closed

Can add a new dev dependency - Key "dev-dependencies" already exists #3103

cda2024 opened this issue Aug 13, 2024 · 4 comments
Labels
🐛 bug Something isn't working

Comments

@cda2024
Copy link

cda2024 commented Aug 13, 2024

Steps to reproduce

I got a project with some dev-dependencies

[tool.pdm.dev-dependencies]
test = [
    "pytest", "pytest-cov"
]

Actual behavior

When I try to add a new one with
pdm add -dG certs altgraph
I get:

No module named 'pyshacl'
INFO: Adding group certs to lockfile
Adding packages to certs dev-dependencies: altgraph
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\users\uuu\.local\bin\pdm.exe\__main__.py", line 7, in <module>
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 346, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 264, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 259, in main
    self.handle(project, options)
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 195, in handle
    command.handle(project, options)
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\add.py", line 71, in handle
    self.do_add(
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\add.py", line 149, in do_add
    all_dependencies = project.all_dependencies
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 365, in all_dependencies
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 624, in __getitem__
    item = self.item(key)
           ^^^^^^^^^^^^^^
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 472, in item
    return OutOfOrderTableProxy(self, idx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 811, in __init__
    self._internal_container._validate_out_of_order_table()
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 154, in _validate_out_of_order_table
    self._validate_out_of_order_table(k)
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 158, in _validate_out_of_order_table
    OutOfOrderTableProxy(self, self._map[key])
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 806, in __init__
    self._internal_container.append(k, v, validate=False)
  File "C:\Users\uuu\AppData\Local\pipx\pipx\venvs\pdm\Lib\site-packages\tomlkit\container.py", line 265, in append
    raise KeyAlreadyPresent(key)
tomlkit.exceptions.KeyAlreadyPresent: Key "dev-dependencies" already exists.



Expected behavior

New dependency was added

[tool.pdm.dev-dependencies]
test = [
    "pytest", "pytest-cov"
]
certs = [
    "altgraph"
]

Environment Information

Both 2.17.1 and 2.17.3 will fail

# Paste the output of `pdm info && pdm info --env` below:

No module named 'pyshacl'
INFO: Inside an active virtualenv C:\Dev\XXX\.venv, reusing it.
Set env var PDM_IGNORE_ACTIVE_VENV to ignore it.
PDM version:
  2.17.3
Python Interpreter:
  C:\Dev\XXX\.venv\Scripts\python.exe (3.11)
Project Root:
  C:/Dev/XXX
Local Packages:


No module named 'pyshacl'
INFO: Inside an active virtualenv C:\Dev\XXX\.venv, reusing it.
Set env var PDM_IGNORE_ACTIVE_VENV to ignore it.
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.7",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19045",
  "python_full_version": "3.11.7",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}
@cda2024 cda2024 added the 🐛 bug Something isn't working label Aug 13, 2024
@cda2024
Copy link
Author

cda2024 commented Aug 13, 2024

Btw.
pdm import -dG certs --format requirements altgraph.req -v
will work.
Content of altgraph.req
altgraph

certs = ["altgraph"] was added to [tool.pdm.dev-dependencies]

@frostming
Copy link
Collaborator

This may be related to the structure of the TOML file. Can you show your pyproject.toml?

@cda2024
Copy link
Author

cda2024 commented Aug 14, 2024

Of courese, here it is:

[project]
name = "myproject"
requires-python = ">=3.11"
author = "unknown"
author_email = "unknown@xxx"
maintainers = [
    { name = "me", email = "me@xxx.de" },
]
description = "my desc"
readme = "README.md"
dependencies = [
    "pandas",
    "pandas-stubs",
    "types-openpyxl",
    "openpyxl",
    "xlsxwriter",
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: Implementation :: CPython",
    "Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]
authors = [
    { name = "me", email = "me@xxx.de" },
]
keywords = [
    "a",
    "b",
]

[project.license]
text = "the bank"

[tool.pdm.dev-dependencies]
test = [
    "pytest", "pytest-cov"
]
pyflakes = [
    "pyflakes",
]
bandit = [
    "bandit",
]
black = [
    "black",
]
yamllint = [
    "yamllint",
]
pyroma = [
    "pyroma",
]
mypy = [
    "mypy",
    "pandas-stubs"
]
dodgy = [
    "dodgy",
]
flake8 = [
    "flake8",
]
jake = [
    "jake>=3.0.10",
]
pylama = [
    "pylama"
]

[project.urls]
gitlab = "https://gitlab.xxx.int/proj"

[tool.setuptools.package-data]
esgco2 = [
    "data/*",
]

[tool.pyprojectx]
main = [
    "pdm",
]

[tool.pyprojectx.venv]
dir = "@PROJECT_DIR/.venv"

[tool.pdm]
distribution = true

[build-system]
requires = [
    "pdm-backend",
]
build-backend = "pdm.backend"

[tool.pdm.version]
source = "file"
path = "./__version__.py"

@frostming
Copy link
Collaborator

It was fixed by tomlkit 0.13.2, you can upgrade it by:

pdm self add --pip-args=-U tomlkit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants