-
Notifications
You must be signed in to change notification settings - Fork 3k
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
More refactoring of req_set #2587
Conversation
f2c1fac
to
6dd7605
Compare
Really nice refactor :) |
req_to_install, finder) | ||
if req_to_install.satisfied_by: | ||
logger.info( | ||
'Requirement already %s: %s', skip_reason, |
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 think the conditional logic has changed here. Previously these logging statements would only ever happen if req_to_install.editable
was False
and req.ignore_installed
was also False
, however now the logging statement will be attempted if req_to_install.editable
is False
only.
I think the
if req_to_install.satisfied_by:
skip_reason = self._check_skip_installed(req_to_install, finder)
if req_to_install.satisfied_by:
logger.info(...)
was changed to
if req_to_install.satisfied_by:
skip_reason = self._check_skip_installed(req_to_install, finder)
if req_to_install.satisfied_by:
logger.info(...)
That would restore the old conditional logic. It would also fix a problem where skip_reason
might be unset (If --ignore-installed
is being used and the item is already installed).
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.
Hmm, doing that here would change the logging down below though, since that needs to know if we're supposed to skip install or not to know if it needs to execute, not just execute only when we are ignoring the install.
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.
Ok, so maybe the real answer here is to change
if req_to_install.satisfied_by:
skip_reason = self._check_skip_installed(req_to_install, finder)
if req_to_install.satisfied_by:
logger.info(...)
else:
if req_to_install.link and req_to_install.link.scheme == "file"):
path = url_to_path(req_to_install.link.url)
logger.info(...)
else:
logger.info(...)
to
skip_reason = None
if req_to_install.satisfied_by:
skip_reason = self._check_skip_installed(req_to_install, finder)
if skip_reason is not None and req_to_install.satisfied_by:
logger.info(...)
else:
if req_to_install.link and req_to_install.link.scheme == "file"):
path = url_to_path(req_to_install.link.url)
logger.info(...)
else:
logger.info(...)
I'd also prefer an empty line between the two if statement chains just to separate them more cleanly (as I showed in my example).
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.
Looking further, I wonder if we really need the skip_reason
variable. It appears that the only time this will actually be skipped is if the version is up to date. So we could just assume that's what it is and drop that variable all together? In that case your code as written is fine, just move the up-to-date
information into the string and return a boolean from _check_skip_installed()
instead. This might work better with the code down below.
I'd still like the newline though.
Overall I like this cleanup, but I added some comments to it. |
* Move the caching of find_requirement into find_requirement. * Move the decision to set / not-set link into InstallRequirement.
It makes no sense to say we're doing something we're not.
We had several overly-scope variables in prepare_files which weren't needed. install is fully modelled by satisfied_by, if we move some logic into the right guarded conditions, which this does. not_found was already obsolete. best_installed really only needed to exist and be checked within the index-consulting upgrade block.
This is now isolated enough to sanely factor out. Yay.
Still need to chat with dstufft on that.
This is a small change to make prepare_file easier to read. It is slightly complicated by the round-about way it was being assigned in non-editable cases.
This makes the code in IsSDist a bit simpler.
We had what looked like buggy code - nothing happening when link is false - but actually link is always true by that point.
This allows introducing detection logic for different sources of source trees.
No description provided.