tox-dev / pyproject-fmt

MIT License
166 stars 26 forks source link

Deletes second platform dependency #231

Closed hugovk closed 2 months ago

hugovk commented 2 months ago

Given config like this, which is meant to install a dependency on macOS and Windows, but not Linux:

[project]
name = "testing"
classifiers = [
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.8",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
]
dependencies = [
  'pyperclip; platform_system == "Darwin"',
  'pyperclip; platform_system == "Windows"',
]

pyproject-fmt 2.1.3 deletes the first dependency:

❯ pyproject-fmt pyproject.toml
--- pyproject.toml

+++ pyproject.toml

@@ -9,6 +9,5 @@

   "Programming Language :: Python :: 3.12",
 ]
 dependencies = [
-  'pyperclip; platform_system == "Darwin"',
-  'pyperclip; platform_system == "Windows"',
+  "pyperclip; platform_system=='Windows'",
 ]

If I switch them so Windows is first instead, it deletes the Windows one.

I guess it thinks they're duplicates, without considering the platform_system?

gaborbernat commented 2 months ago

PR welcome 🤗