-
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
bpo-40059: tomllib #2
Conversation
Hey @encukou and @hauntsaninja ! The tomllib PEP is obviously not accepted yet, but I had some spare time so integrated Tomli to the stdlib. Here's the results. I made minimal docs already too. I've included all Tomli's tests, which means almost 1MB of test data. @encukou perhaps you can tell if this is too much for a single cpython module? EDIT: The Files changed tab of this PR on GitHub kills my browser (probably due to the amount of test files). Here's a link to it but with test data filtered: https://github.com/hukkin/cpython/pull/2/files?file-filters%5B%5D=.h&file-filters%5B%5D=.md&file-filters%5B%5D=.py&file-filters%5B%5D=.rst&file-filters%5B%5D=No+extension&show-viewed-files=true |
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.
This is awesome!
encukou will be able to give you better advice about tests, but I believe for zoneinfo and importlib.metadata some tests with extra deps or fixtures exist outside the CPython code base.
Ah, here's the notification I missed. Sorry for that! |
Thanks a lot for the review @merwok ! I'll have a closer look a bit later. I think some of the comments have to do with the fact that I tried to minimize the steps needed to take to go from Tomli (backport) to tomllib (stdlib) in order to minimize maintenance effort. Perhaps that's not something I should do though? |
I wouldn't worry about the extra comments, if they simplify maintaining
|
I was not thinking of the backport! Then I agree with Petr, except for the license text. |
|
||
import tomllib | ||
|
||
toml_str = """ |
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.
load
wants a binary stream but loads
a text string?
If this is intentional, it may be worth pointing out here.
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.
Closing in favour of python#31498 |
Steps taken
Move everything in
tomli:src/tomli
toLib/tomllib
. Excludepy.typed
.Remove
__version__ = ...
line fromLib/tomllib/__init__.py
Move everything in
tomli:tests
toLib/test/test_tomllib
. Exclude the following test data dirs recursively:tomli:tests/data/invalid/_external/
tomli:tests/data/valid/_external/
Create
Lib/test/test_tomllib/__main__.py
:Add the following to
Lib/test/test_tomllib/__init__.py
:Also change
import tomli as tomllib
toimport tomllib
.In
cpython/Lib/tomllib/_parser.py
replace__fp
withfp
and__s
withs
. Add the/
toload
andloads
function signatures.Run
make regen-stdlib-module-names
Create
Doc/library/tomllib.rst
and reference it inDoc/library/fileformats.rst