tox-dev/pyproject-fmt

Sorting of some tables seems to be random

Closed this issue · 2 comments

Consider the following pyproject.toml:

[tool.ruff]
line-length = 88
src = [
  "src",
  "tests",
  "docs",
]

[tool.ruff.format]
docstring-code-format = true
preview = true

[tool.ruff.lint]
preview = true
select = [
  "F",
  "E",
  "W",
  "EM",
  "PD",
]

[tool.ruff.lint.per-file-ignores]
"src/*" = [
  "PD", # pandas-vet
]

[tool.ruff.lint.flake8-errmsg]
max-string-length = 30

Running pyproject-fmt (2.0.3) against it produces different results on sequential runs. I used the --check flag to confirm the randomness (as opposed to the result being affected by any previous changes made by the tool).

The following command was used then

pyproject-fmt --check pyproject.toml 

Example 1

--- pyproject.toml

+++ pyproject.toml

@@ -10,6 +10,8 @@

 docstring-code-format = true
 preview = true
 
+[tool.ruff.lint.flake8-errmsg]
+max-string-length = 30
 [tool.ruff.lint]
 preview = true
 select = [
@@ -24,6 +26,3 @@

 "src/*" = [
   "PD", # pandas-vet
 ]
-
-[tool.ruff.lint.flake8-errmsg]
-max-string-length = 30

Example 2

--- pyproject.toml

+++ pyproject.toml

@@ -6,10 +6,8 @@

   "docs",
 ]
 
-[tool.ruff.format]
-docstring-code-format = true
-preview = true
-
+[tool.ruff.lint.flake8-errmsg]
+max-string-length = 30
 [tool.ruff.lint]
 preview = true
 select = [
@@ -25,5 +23,6 @@

   "PD", # pandas-vet
 ]
 
-[tool.ruff.lint.flake8-errmsg]
-max-string-length = 30
+[tool.ruff.format]
+docstring-code-format = true
+preview = true

Example 3

No changes 😅

$ pyproject-fmt --check pyproject.toml
no change for pyproject.toml

Let me know if this better reported in https://github.com/tox-dev/pyproject-fmt-rust :)

Yeah I think this is tox-dev/pyproject-fmt-rust#8

Ah this is probably a duplicate of #205 and both are now fixed by #210.

EDIT: both are probably duplicate of #201