Skip to content
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

Test with tomli #219

Merged
merged 6 commits into from Jan 18, 2022
Merged

Test with tomli #219

merged 6 commits into from Jan 18, 2022

Conversation

fridex
Copy link
Collaborator

@fridex fridex commented Jan 10, 2022

This introduces a breaking change

  • No

Description

Check if micropipenv is compatible with tomli.

@sesheta sesheta added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 10, 2022
@sesheta
Copy link
Member

sesheta commented Jan 10, 2022

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from fridex after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fridex
Copy link
Collaborator Author

fridex commented Jan 10, 2022

/hold

@sesheta sesheta added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 10, 2022
@frenzymadness
Copy link
Collaborator

I've tried to reproduce the error and it seems that the unencrypted git:// protocol is no longer supported, see https://github.blog/2021-09-01-improving-git-protocol-security-github/
We should change all git:// to https://. I'm running the tests locally for one of the new environments with this change applied and I'll see what happens.

@frenzymadness
Copy link
Collaborator

And the error is: module 'tomli' has no attribute 'TomlDecodeError'. It seems that the name in tomli is different (TOMLDecodeError): https://github.com/hukkin/tomli/blob/5701c0be3a76322372f58af0e19163037fec7663/src/tomli/_parser.py#L49

@frenzymadness
Copy link
Collaborator

We can handle this in _import_toml or we can open an upstream issue - it might make sense to create an alias to have the same exception name in these backends. What do you think?

@fridex
Copy link
Collaborator Author

fridex commented Jan 11, 2022

Thanks for checking this! 👍🏻

We can handle this in _import_toml or we can open an upstream issue - it might make sense to create an alias to have the same exception name in these backends. What do you think?

+1, might be a good idea. Let's see what's the upstream opinion on this.

@frenzymadness
Copy link
Collaborator

Upstream issue: hukkin/tomli#167

@frenzymadness
Copy link
Collaborator

The issue has been closed. We have to handle this here. Do you wanna do it or should I take a look?

@fridex
Copy link
Collaborator Author

fridex commented Jan 11, 2022

The issue has been closed. We have to handle this here. Do you wanna do it or should I take a look?

Oh, that's a pity. It might be good to have it eventually backward compatible with (older) tomli releases anyway if tomli support will be considered. Feel free to take it if you want 👍🏻

BTW there are also other libraries that manipulate with TOML besides pytoml and toml which micropipenv currently supports - rtoml, pytomlpp, qtoml, tomlkit (from tomli docs). It looks like tomli is now vendored in pip, hence this testing PR. I'm unsure which TOML parsers we should support. What is your opinion on this?

@harshad16 harshad16 removed their request for review January 11, 2022 13:59
@frenzymadness
Copy link
Collaborator

During working on this, I've discovered that our support for pytoml is not complete :( The problem is that we do not have any negative tests for this

micropipenv/micropipenv.py

Lines 239 to 245 in d0c37c1

try:
with open(pipfile_path) as input_file:
return toml.load(input_file)
except toml.TomlDecodeError as exc:
raise FileReadError("Failed to parse Pipfile: {}".format(str(exc))) from exc
except Exception as exc:
raise FileReadError(str(exc)) from exc

What I mean is that pytoml also does not have TomlDecodeError but we don't know about it because the except clause is not evaluated until an exception is raised in the try block.

@sesheta sesheta added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 12, 2022
@frenzymadness
Copy link
Collaborator

Take a look at my implementation. I'm not sure why some tests failed. Will try to run the same envs locally.

@frenzymadness
Copy link
Collaborator

It seems to me that the very old pip does not work well with the latest setuptools so I'll have to find a way how to pin setuptools to some older version which won't be an easy task. I don't want to create a new variable for that. I'd rather somehow merge that information to one variable specifying all the dependencies at once.

@frenzymadness
Copy link
Collaborator

It seems that setuptools<40 is too old for Python 3.9, testing again with <60.

@frenzymadness
Copy link
Collaborator

Almost all green. pre-commit is complaining about trailing whitespace in a file we haven't touched here but I'll fix it in the next commit to make it happy.

@frenzymadness frenzymadness removed their request for review January 13, 2022 13:33
@frenzymadness
Copy link
Collaborator

@fridex I cannot request a review from you because you are the author of this PR so I've assigned it to you.

@frenzymadness
Copy link
Collaborator

BTW there are also other libraries that manipulate with TOML besides pytoml and toml which micropipenv currently supports - rtoml, pytomlpp, qtoml, tomlkit (from tomli docs). It looks like tomli is now vendored in pip, hence this testing PR. I'm unsure which TOML parsers we should support. What is your opinion on this?

To answer your question – Having toml is a good idea because it's defacto standard now and we have it in Fedora. pytoml is important for us (even it's an abandoned project) because we have it in RHEL 8. And finally, tomli is a good idea to add because there is some probability that it'll be a part of the standard library soon, see: hukkin/tomli#141

Copy link
Collaborator Author

@fridex fridex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice! Thanks for taking care of this. 👍🏻 LGTM

@fridex
Copy link
Collaborator Author

fridex commented Jan 18, 2022

@frenzymadness I'm happy to have this merged if you are fine with that.

@frenzymadness frenzymadness merged commit 565886c into thoth-station:master Jan 18, 2022
@fridex fridex deleted the tomli branch January 18, 2022 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants