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

WIP: Add requirement parsing module. #7020

Closed
wants to merge 9 commits into from
Closed

Conversation

chrahunt
Copy link
Member

@chrahunt chrahunt commented Sep 15, 2019

This PR adds a new module: req.parsing

req.parsing encapsulates the "pure" parsing logic needed to map incoming user requirements to something meaningful (i.e. RequirementInfo). This also makes it more clear what we accept in terms of syntax. This has the following changes in behavior:

  1. file URLs must contain file:// and be absolute - originally file:./relative/path was accepted
  2. referenced file:// paths must exist (previously paths that looked like archive files did not need to exist)

For now only install_req_from_line has been updated. If this looks fine then install_req_from_editable and install_req_from_req_string can be done in a followup PR.

Progresses #7019.

@chrahunt chrahunt added skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code labels Sep 15, 2019
This prevents a circular import since req.constructors will depend on
req.parsing.
To start, we use the parsed link instead of populating it in several
places.

We no longer need to normalize relative URLs since the requirement
string must be either:

1. a relative path (e.g. `.` or `./example`), which gets normalized
   by `parse_requirement_text`, or
2. an absolute file URL
Since the lower-level parsing already determined it's a file path,
we can just check whether it's a directory.
A single '=' may only be applicable to direct references or named
references, since they are the ones that allow version specifiers.
Previously, non-existent file paths were falling through to the
Requirement parsing and it was failing at that point. Now we
specifically require that any mentioned files exist.
@cjerdonek
Copy link
Member

Can you separate behavior changes from refactoring? It’s very hard to evaluate when both are happening at the same time (changes in logic combined with moving stuff around, etc).

@chrahunt
Copy link
Member Author

Sure. For cases where an intermediate state would not be valid (e.g. some block gets moved above a declaration), would you prefer a comment saying something like "not valid, will be changed shortly" above the relocation or do you assume that something that looks wrong in one commit will be resolved in the next?

@cjerdonek
Copy link
Member

By “invalid,” do you just mean style issues that might not normally pass review muster? In those cases, I think you can address it in comments in the PR (e.g. “don’t worry about method ordering in this PR because I’m planning to address that in a subsequent PR”). If it’s going to be addressed shortly, I don’t think we need to include it in the code itself IMO.

@chrahunt
Copy link
Member Author

When you said

Can you separate behavior changes from refactoring

I assumed you meant in separate commits. So one commit for a move and then one commit for the change, which makes sense to me.

By "invalid" I meant if commit A moves some code but maybe it is broken in some obvious way (for example, moving a block of code above the initialization of a variable it needs), is that OK as-is if it gets fixed in B when the actual change occurs?

@cjerdonek
Copy link
Member

I think the code should be working in each commit. For example, in a refactoring PR, each commit would have the same behavior as the previous (and in particular the code would still be working).

I think refactoring changes should be in their own PR's separate from behavior changes (especially large changes). Separate from that, within a refactoring PR, it can help to put e.g. function moves and changes to the body of a function in separate commits. (That way you can see what is changing.) But when function moves, (behavior-preserving) refactoring changes, and behavior changes are all happening all at once, it makes everything that much harder to review and discuss.

@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Sep 17, 2019
@chrahunt
Copy link
Member Author

Still planning on going this direction, but more carefully. Thanks for the feedback @cjerdonek!

@chrahunt chrahunt closed this Sep 20, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Oct 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation needs rebase or merge PR has conflicts with current master skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants