2 ms·
Regarding one proposed variation: > Make packaging.wheels a table > One could see writing out wheel file details as a table keyed on the file name. For exampl
by zahlman 2y ago
Regarding one proposed variation:
> Make packaging.wheels a table
> One could see writing out wheel file details as a table keyed on the file name. For example ... It’s entirely a structural change which some may (not) prefer.
I'm strongly in favour, since this would allow writing the data without an inline table. Brett Cannon suggests that the current
[[packages]]
# other information about the package here
wheels = [
"attrs-23.2.0-py3-none-any.whl" = {upload-time = 2023-12-31T06:30:30.772444Z, url = "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl", size = 60752, hashes = {sha256 = "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"} }
]
could become
[[packages]]
# other information about the package here
[packages.wheels]
"attrs-23.2.0-py3-none-any.whl" = {upload-time = 2023-12-31T06:30:30.772444Z, url = "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl", size = 60752, hashes = {sha256 = "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}
but seems to overlook that, thanks to the flexibility in the TOML spec, it could also become
[[packages]]
# other information about the package here
[packages.wheels."attrs-23.2.0-py3-none-any.whl"]
upload-time = 2023-12-31T06:30:30.772444Z
url = "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl"
size = 60752
hashes.sha256 = "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"
which I would say is far easier to read. I would consider this a straightforward application of the "flat is better than nested" principle; while the data is inherently nested, its representation doesn't need to be.
- zahlman 2y agoOn reflection (and testing), my thought here doesn't stand up. Or rather: I still like writing the data without inline structures, but it doesn't require changing [[packages.wheels]] to a table. TOML perfectly allows for arrays-of-tables to be put within arrays-of-tables, without any inline syntax, so we could just as well have: [[packages]] # other information about the package here [[packages.wheels]] name = "attrs-23.2.0-py3-none-any.whl" upload-time = 2023-12-31T06:30:30.772444Z url = "https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl" size = 60752 hashes.sha256 = "99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1" In TOML, subsequent `[[packages.wheels]]` tables would specify another wheel for the most recently mentioned package; `[[packages]]` would close off the details (including wheels) for a package and start the next one.