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

Custom lock-file serialization #3909

Merged
merged 1 commit into from
May 30, 2024
Merged

Conversation

ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented May 29, 2024

Summary

This PR changes the lock-file format to use inline tables for wheels and source distributions, which currently use separate tables that make the file harder to follow.

[[distribution]]
name = "typing-extensions"
version = "4.10.0"
source = "registry+https://pypi.org/simple"

- [distribution.sdist]
- url = "https://files.pythonhosted.org/packages/16/3a/0d26ce356c7465a19c9ea8814b960f8a36c3b0d07c323176620b7b483e44/typing_extensions-4.10.0.tar.gz"
- hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"
- size = 77558
-
- [[distribution.wheel]]
- url = "https://files.pythonhosted.org/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl"
- hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"
- size = 33926

+ sdist = { url = "https://files.pythonhosted.org/packages/16/3a/0d26ce356c7465a19c9ea8814b960f8a36c3b0d07c323176620b7b483e44/typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb", size = 77558 }
+ wheel = [{ url = "https://files.pythonhosted.org/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475", size = 33926 }]

The downside is that the inline-tables end up quite long and TOML doesn't support line breaks in inline tables, yet.

Part of #3611.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I think the main question I have here is whether line breaks are inserted if there is more than one entry in the array. I think all the tests/examples currently only have one entry in these arrays, so it's hard to tell. I know line breaks can't be inserted in the inline tables themselves, but they can be inserted between the inline tables within the array. If there are no line breaks then we probably can't use this approach as the lines would get absurdly long.

I like the to_toml approach here. :)

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still makes for very long lines, but I feel like this is an improvement on the status quo.

The other possibility is to keep the table arrays (not inline tables) and just indent them.

@ibraheemdev ibraheemdev force-pushed the lock-format branch 2 times, most recently from a292476 to 4c92a74 Compare May 30, 2024 18:54
Copy link

codspeed-hq bot commented May 30, 2024

CodSpeed Performance Report

Merging #3909 will not alter performance

Comparing ibraheemdev:lock-format (8c570f1) with main (d3b7d80)

Summary

✅ 13 untouched benchmarks

@ibraheemdev ibraheemdev enabled auto-merge (squash) May 30, 2024 19:07
@ibraheemdev ibraheemdev merged commit 85183c1 into astral-sh:main May 30, 2024
46 checks passed
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 this pull request may close these issues.

2 participants