Update pyproject-toml to support PEP 639 (#13902)

Fixes #13869
This commit is contained in:
konsti 2024-11-18 15:16:02 +01:00 committed by Micha Reiser
parent 8b925ea626
commit b46cc6ac0b
10 changed files with 77 additions and 47 deletions

View file

@ -0,0 +1,6 @@
[project]
name = "hello-world"
version = "0.1.0"
# PEP 639 - passing
license = "MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)"
license-files = ["LICEN[CS]E*", "AUTHORS*", "licenses/LICENSE.MIT"]

View file

@ -1,5 +1,3 @@
# license-files is wrong here
# https://github.com/PyO3/maturin/issues/1615
[build-system]
requires = [ "maturin>=0.14", "numpy", "wheel", "patchelf",]
build-backend = "maturin"

View file

@ -372,7 +372,8 @@ mod tests {
#[test_case(Rule::InvalidPyprojectToml, Path::new("bleach"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("invalid_author"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("maturin"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("maturin_gh_1615"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("various_invalid"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("pep639"))]
fn invalid_pyproject_toml(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let path = test_resource_path("fixtures")

View file

@ -2,7 +2,7 @@
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: Version specifier `>=1.1.0<1.2` doesn't match PEP 440 rules
pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: after parsing `1.1.0`, found `<1.2`, which is not part of a valid version
tinycss2>=1.1.0<1.2
^^^^^^^^^^^
|

View file

@ -2,11 +2,13 @@
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:6:84: RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string
pyproject.toml:5:11: RUF200 Failed to parse pyproject.toml: a table with 'name' and/or 'email' keys
|
4 | # Ensure that the spans from toml handle utf-8 correctly
5 | authors = [
6 | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 }
| ^ RUF200
7 | ]
3 | version = "0.1.0"
4 | # Ensure that the spans from toml handle utf-8 correctly
5 | authors = [
| ___________^
6 | | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 }
7 | | ]
| |_^ RUF200
|

View file

@ -1,13 +0,0 @@
---
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:9:17: RUF200 Failed to parse pyproject.toml: wanted string or table
|
7 | [project]
8 | name = "..."
9 | license-files = [ "license.txt",]
| ^^^^^^^^^^^^^^^^^ RUF200
10 | requires-python = ">=3.8"
11 | requires-dist = [ "maturin>=0.14", "...",]
|

View file

@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---

View file

@ -0,0 +1,15 @@
---
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:10:16: RUF200 Failed to parse pyproject.toml: URL requirement must be preceded by a package name. Add the name of the package before the URL (e.g., `package_name @ /path/to/file`).
...
^^^
|
8 | requires-python = ">=3.8"
9 | requires-dist = [ "maturin>=0.14", "...",]
10 | dependencies = [ "packaging", "...",]
| ^^^^^^^^^^^^^^^^^^^^^^ RUF200
11 | zip-safe = false
12 | version = "..."
|