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

pdm update -u moves [tool.pdm] section to the bottom of pyproject.toml #2251

Closed
1 task done
mattmess1221 opened this issue Sep 11, 2023 · 1 comment
Closed
1 task done
Labels
🐛 bug Something isn't working

Comments

@mattmess1221
Copy link

mattmess1221 commented Sep 11, 2023

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Given a pyproject.toml like this.

[project]
name = "foobar"
version = "0.0.0"
requires-python = ">=3.7,<4.0"

[tool.pdm]
[tool.pdm.dev-dependencies]
dev = [
  "pytest>=6.0.0"
]

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

[tool.pytest.ini_options]
addopts = "--someoptions"

Actual behavior

Running pdm update -u will create a pyproject.toml that looks like this.

[project]
name = "foobar"
version = "0.0.0"
requires-python = ">=3.7,<4.0"

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

[tool.pytest.ini_options]
addopts = "--someoptions"

[tool.pdm]
[tool.pdm.dev-dependencies]
dev = [
  "pytest>=7.4.2"
]

Expected behavior

I expect it to keep the same order of keys when writing back to the file system.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
❯ pdm info && pdm info --env
PDM version:
  2.9.1
Python Interpreter:
  .../project/.venv/bin/python (3.10)
Project Root:
  .../project
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.12",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.90.1-microsoft-standard-WSL2",
  "platform_system": "Linux",
  "platform_version": "#1 SMP Fri Jan 27 02:56:13 UTC 2023",
  "python_full_version": "3.10.12",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}
     
@mattmess1221 mattmess1221 added the 🐛 bug Something isn't working label Sep 11, 2023
@frostming
Copy link
Collaborator

pdm/src/pdm/project/core.py

Lines 526 to 531 in 67e7894

if isinstance(self.pyproject._data["tool"], OutOfOrderTableProxy):
# In case of a separate table, we have to remove and re-add it to make the write correct.
# This may change the order of tables in the TOML file, but it's the best we can do.
# see bug pdm-project/pdm#2056 for details
del self.pyproject._data["tool"]["pdm"]
self.pyproject._data["tool"]["pdm"] = settings

See #2056

@frostming frostming closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2023
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