Skip to content

Custom lock-file serialization - #3909

Merged
ibraheemdev merged 1 commit into
astral-sh:mainfrom
ibraheemdev:lock-format
May 30, 2024
Merged

ibraheemdev merged 1 commit into
astral-sh:mainfrom
ibraheemdev:lock-format

Conversation

@ibraheemdev

@ibraheemdev ibraheemdev commented May 29, 2024 •

Copy link
Copy Markdown
Member

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.

@BurntSushi BurntSushi left a comment

Copy link
Copy Markdown
Member

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. :)

@BurntSushi BurntSushi left a comment

Copy link
Copy Markdown
Member

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
@codspeed

codspeed Bot commented May 30, 2024 •

Copy link
Copy Markdown

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
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