astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.73k stars 1.09k forks source link

Support for PEP 639 in RUF200 #13869

Open henryiii opened 3 weeks ago

henryiii commented 3 weeks ago

In --preview, the following error is shown for PEP 639 style licenses:

tests/packages/spdx/pyproject.toml:5:17: RUF200 Failed to parse pyproject.toml: wanted string or table
  |
3 | version = "1.2.3"
4 | license = "MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)"
5 | license-files = ["LICEN[CS]E*", "AUTHORS*", "licenses/LICENSE.MIT"]
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF200

I don't fully understand the error message (license-files was never a string or table), but it would be good to support PEP 639, at least before this leaves preview (Edit: Ahh, this happens if you run ruff check . even without --preview, I always use pre-commit except for checking --preview).

MichaReiser commented 3 weeks ago

Agree, we should change the validation here.

@konstin do you know why we flag license-files if it isn't a table?

konstin commented 3 weeks ago

The pyproject-toml crate has an outdated version of the PEP, we need to fix this in that crate which will fix the rule.