tox-dev / pyproject-fmt

MIT License
167 stars 27 forks source link

Sorting of some tables seems to be random #206

Closed edgarrmondragon closed 4 months ago

edgarrmondragon commented 4 months ago

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 :)

gaborbernat commented 4 months ago

Yeah I think this is https://github.com/tox-dev/pyproject-fmt-rust/issues/8

edgarrmondragon commented 4 months ago

Ah this is probably a duplicate of https://github.com/tox-dev/pyproject-fmt/issues/205 and both are now fixed by #210.

EDIT: both are probably duplicate of https://github.com/tox-dev/pyproject-fmt/issues/201