astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.82k stars 467 forks source link

TOML parser raises when inline table is spread on multiple lines #1108

Closed baggiponte closed 5 months ago

baggiponte commented 5 months ago

Steps to Reproduce

Define any script as inline table:

[tool.rye.scripts]
devserver = {
  cmd = "flask run --debug", env = { FLASK_APP = "./hello.py" }
}

Expected Result

The server runs

Actual Result

rye run devserver
error: failed to parse pyproject.toml (at '/blablabla/pyproject.toml')

Caused by:
    TOML parse error at line 40, column 8
       |
    40 | devserver = {
       |        ^
    invalid inline table
    expected `}`

Version Info

rye 0.34.0 commit: 0.34.0 (d31340178 2024-05-20) platform: macos (aarch64) self-python: cpython@3.12.1 symlink support: true uv enabled: true

Stacktrace

No response

davfsa commented 5 months ago

This is expected. The TOML spec does not allow splitting inline tables across multiple lines. You will have to keep it inline

See https://toml.io/en/v1.0.0#inline-table

Inline tables are intended to appear on a single line. A terminating comma (also called trailing comma) is not permitted after the last key/value pair in an inline table. No newlines are allowed between the curly braces unless they are valid within a value. Even so, it is strongly discouraged to break an inline table onto multiples lines. If you find yourself gripped with this desire, it means you should be using standard tables.

charliermarsh commented 5 months ago

Yeah, unfortunately this is correct.

baggiponte commented 5 months ago

Oh I did not know. Should we add some message to document the error? Otherwise we can close the issue.