5 ms·
Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
by SushiHippie 3y ago
Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
- frfl 3y agoMaybe because then you can just inline a pyproject text without any extra effort and the existing tooling for pyproject parsing can work in both cases?
- SushiHippie 3y agoYeah copying a pyproject.toml seems like a valid case. But I'd guess that the toml will be parsed to something like a dict anyway after reading the file/string.
- Verath 3y agoI think they do kind of answer that under the "Why not use (possibly restricted) Python syntax?". I understand their reasoning to be that it would require other tools to know how to parse python. Which is much more difficult than parsing toml
- SushiHippie 3y agoAh okay, I read this but I've understood it in another way. I thought they meant using multiple variables could become a problem. But I guess it makes some sense to not parse the python ast tree but to parse with a regex.
- lijok 3y agoIt's probably because pyproject.toml is the direction in which the python ecosystem is going. On that note, I will never understand why they chose .toml instead of just json or yaml..
- Denvercoder9 3y ago> On that note, I will never understand why they chose .toml instead of just json or yaml.. https://peps.python.org/pep-0518/#other-file-formats https://peps.python.org/pep-0518/#other-file-formats
- SushiHippie 3y agoThanks this also gave another reason why they didn't use a dict for configuration https://peps.python.org/pep-0518/#python-literals https://peps.python.org/pep-0518/#python-literals
- lijok 3y agoI think "easy for humans to edit" is where I mostly disagree with. To this day I have not worked with anyone that understood the .toml format.
- heinrich5991 3y agoHey. I think I understand the .toml format. What do you want to know?
- paulddraper 3y agoHow much time have you spent towards TOML vs -- say -- YAML? More editable than JSON and far simpler than YAML. --- The Rust ecosystem also uses TOML.
- ElectricalUnion 3y agoYAML is only fun when you're not tripping in the numerous landmines in the way: https://noyaml.com/ https://noyaml.com/
- SushiHippie 3y agoYes, but you can write a pyproject toml file also as a python dictionary. Instead of: [project] requires-python = ">=3.11" dependencies = [ "requests<3", "rich", ] You could write: { "project": { "requires-python":">=3.11", "dependencies" : [ "requests<3", "rich" ] }
- lijok 3y agoNo way ! Gotta think carefully about this... Might upset some coworkers
- aldanor 3y agoYAML is one of the most ambiguous formats out there, and definitely an overkill for what's needed to describe metadata. JSON - not the most convenient to use for human beings, too much quoting, not too git friendly because of disallowed trailing commas, etc. TOML sits somewhere inbetween, easy to write but the spec is very short; also being used in Rust and a few other places.
- bandyaboot 3y agoIt does seem like over-complicating things for a dynamic language not to use itself as the standard configuration format.