Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing newline added when TOML array is empty #1083

Closed
my1e5 opened this issue May 14, 2024 · 0 comments · Fixed by #1084
Closed

Trailing newline added when TOML array is empty #1083

my1e5 opened this issue May 14, 2024 · 0 comments · Fixed by #1084

Comments

@my1e5
Copy link
Contributor

my1e5 commented May 14, 2024

Steps to Reproduce

Create a new rye project and you will see that the empty arrays in pyproject.toml are formatted on one line.

$ rye init hello
$ cd hello/
$ cat pyproject.toml
[project]
name = "hello"
version = "0.1.0"
authors = ...
dependencies = []
readme = "README.md"
requires-python = ">= 3.8"

For example, dependencies = [].
If you add a dependency, it will reformat the array like so

$ rye add requests
dependencies = [
    "requests>=2.31.0",
]

But then if you remove that dependency

$ rye remove requests
dependencies = [
]

an extra \n remains.

Expected Result

I expected an empty array to not contain a \n.

dependencies = []

Actual Result

dependencies = [
]

Version Info

$ rye --version
rye 0.33.0
commit: 0.33.0 (58523f69f 2024-04-24)
platform: macos (x86_64)
self-python: cpython@3.12.3
symlink support: true
uv enabled: true

Stacktrace

No response

charliermarsh pushed a commit that referenced this issue May 15, 2024
Closes #1083

A trailing newline is only added if there are dependencies or comments
in the array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant