-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
pdm is sensitive to section order in pyproject.toml
with unhelpful error messages
#3296
Comments
Adding an empty |
我也遇到了同样的报错,经过一段时间的测试,发现了问题所在。 引用您的文件内容: [tool.pdm.scripts]
[tool.pdm]
distribution = false 按顺序处理文件内容,创建 例如: [tool.pdm] # this frist
distribution = false
[tool.pdm.scripts] # and than add other sub keys that's all, enjoy it!!! |
Thanks @jiangbaihe ! Google Translate says:
For example:
I still think the error message is very unhelpful. |
I would say it comes from 1 of the 2 underlying pdm libraries, But I think this is a general issue with this library and so this bug must be reported upstream (it should be easy to craft a minimal reproducible test case). Given the TOML specs says:
It's probable this case is just not tested or supported upstream. |
Here is the stack trace: INFO: Adding group dev to lockfile
Adding packages to dev dev-dependencies: -e file:///${PROJECT_ROOT}/#egg=pdmtest
Traceback (most recent call last):
File "/home/chris/pdm/bin/pdm", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/core.py", line 392, in main
return core.main(args or sys.argv[1:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/core.py", line 270, in main
raise cast(Exception, err).with_traceback(traceback) from None
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/core.py", line 265, in main
self.handle(project, options)
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/core.py", line 195, in handle
command.handle(project, options)
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/cli/commands/add.py", line 71, in handle
self.do_add(
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/cli/commands/add.py", line 146, in do_add
group_deps = project.add_dependencies(requirements, group, selection.dev or False, write=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/project/core.py", line 735, in add_dependencies
setter(deps)
File "/home/chris/pdm/lib/python3.12/site-packages/pdm/project/core.py", line 667, in update_dev_dependencies
del self.pyproject._data["tool"]["pdm"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/home/chris/pdm/lib/python3.12/site-packages/tomlkit/container.py", line 868, in __delitem__
del table[key]
~~~~~^^^^^
File "/home/chris/pdm/lib/python3.12/site-packages/tomlkit/items.py", line 1502, in __delitem__
self.remove(key)
File "/home/chris/pdm/lib/python3.12/site-packages/tomlkit/items.py", line 1472, in remove
self._value.remove(key)
File "/home/chris/pdm/lib/python3.12/site-packages/tomlkit/container.py", line 352, in remove
raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "pdm" does not exist.' |
I think it's this tomlkit bug. Although it would be nice if |
Describe the bug
A simple
pyproject.toml
can causepdm add
to fail with:To reproduce
Run
pdm init
, then replace the contents ofpyproject.toml
with:Then run
pdm add -e . --dev
.Expected Behavior
What actually happens is:
Making random changes to
pyproject.toml
, such as reordering sections or removing the[tool.ruff]
section, makes it work.Environment Information
PDM version:
2.20.1
Python Interpreter:
C:\Users...\Documents\pdmtest.venv\Scripts\python.exe (3.12)
Project Root:
C:/Users/.../Documents/pdmtest
Local Packages:
{
"implementation_name": "cpython",
"implementation_version": "3.12.3",
"os_name": "nt",
"platform_machine": "AMD64",
"platform_release": "10",
"platform_system": "Windows",
"platform_version": "10.0.19045",
"python_full_version": "3.12.3",
"platform_python_implementation": "CPython",
"python_version": "3.12",
"sys_platform": "win32"
}
pdm -v output
Additional Context
No response
Are you willing to submit a PR to fix this bug?
The text was updated successfully, but these errors were encountered: