-
Notifications
You must be signed in to change notification settings - Fork 0
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
PEP ???: TOML #1
Conversation
A general observation: If we don't end up using the |
One concern I have regarding Tomli-W library (whether it goes into the standard library or not): It currently only It also means that we always use
|
Yup, makes sense. The draft currently proposes As it stands, I think we just need: I don't feel strongly about newline sequences used in the document. I'm happy with no change, and as you say, there's a fine workaround. Somewhat related: if we always use |
Soo if say we have the following TOML s = "foo\nbar" a load/dump roundtrip will then write s = """
foo
bar""" Even if this sort of worked when using this particular parser/writer exclusively, at this point TOML semantics have changed, and any other parser is free to translate the newline sequence to |
Yeah, "works with the same parser / writer & TOML and Python are a little fast and loose when it comes to carriage return anyway" is a pretty different promise from "always get the bytes you want". So scratch that :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work once again!
Here's a quick drive-by review. I'll try to do more in-depth, maybe filling in some of the TODOs in the future.
Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
Thanks, made the updates! |
Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
pep-9999.rst
Outdated
|
||
The TOML format is the format of choice for Python packaging, as evidenced by | ||
:pep:`517`, :pep:`518` and :pep:`621`. Including TOML support in the standard | ||
library helps avoid bootstrapping problems for Python build tools. Currently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should unfold what the bootstrapping problems are and why vendoring is necessary:
A PEP517 build requires reading TOML metadata but the standard library is unable to parse it. How do you build the first TOML parser if building it requires a TOML parser? How do you build a build frontend for building the TOML parser if building it also requires TOML? etc.
Overall, this looks great! Thank you for writing it up! |
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>
pep-9999.rst
Outdated
def load(fp: SupportsRead[bytes], /, *, parse_float: Callable[[str], Any] = float) -> dict[str, Any]: ... | ||
def loads(s: str, /, *, parse_float: Callable[[str], Any] = float) -> dict[str, Any]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def load(fp: SupportsRead[bytes], /, *, parse_float: Callable[[str], Any] = float) -> dict[str, Any]: ... | |
def loads(s: str, /, *, parse_float: Callable[[str], Any] = float) -> dict[str, Any]: ... | |
def load(fp: SupportsRead[bytes], /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... | |
def loads(s: str, /, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... |
I think the default argument is not relevant, should be considered an implementation detail, and seems to be a convention to elide it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think it's more useful than the type annotation :)
If removed, the default behavior should be mentioned in the prose (even though it's straightforward).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If removed, the default behavior should be mentioned in the prose (even though it's straightforward).
Yeah I think I'd prefer doing this.
The reason why I'd want to consider this a non-annotated implementation detail is that I fear one day we may find out there is some special case where float(<insert-special-TOML-float-here>)
does not return the appropriate result or even raises ValueError
. If it happens it'd be best to set the default to None
and make the None
correspond to a slightly customized float
callable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, seeing the change to the text... The same argument can be made for the recommendation to use Decimal, can't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that decimal.Decimal
could in theory fail to parse a TOML float? Yeah agreed. But at least that's only a recommendation, not baked into the API specification. Do you think we should change the wording? E.g. "a callable that returns a decimal.Decimal
can be used in cases where precision is important".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this change and adjusted the wording of the decimal.Decimal
bit!
@encukou @hauntsaninja mostly unrelated to this PEP, but since you are both here: I tried to give both of you access to Tomli GitHub and PyPI to address some recent concerns of me getting hit by a bus. 😄 Would be great if at least one of you (optimally both) accepted the invites but if not, no problem, I'll find someone else. I have no expectation of you having to do any work whatsoever. Tomli's scope is small and I enjoy and can manage maintaining it alone. But if I ever disappear for say 6+ months, feel free to take over and start making commits and releases to prevent what happened to |
Thanks! I hope you don't get hit by a bus 😄 Since we've had a couple rounds of editing, I went ahead and opened the PR against python/peps: python#2218 |
No description provided.