-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix pipenv crashes #2388
Fix pipenv crashes #2388
Conversation
Fix IndexError exception when `more_packages` is empty and add the more informal message for argument usage. To reproduce this issue `pipenv install -e`
Add extra check for -i option for fix `AttributeError: 'NoneType'` To reproduce this bug `pipenv install <module> -i`
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.
Thanks for the patch! The logic seems correct to me, but I left some comments about wording and coding styles. The latter is not your fault (the original code is quite confusing to start with), but I feel it is a good chance to refactor it a bit.
This would close #2383.
pipenv/core.py
Outdated
@@ -1889,12 +1889,16 @@ def do_install( | |||
# Capture -e argument and assign it to following package_name. | |||
more_packages = list(more_packages) | |||
if package_name == '-e': | |||
if not more_packages: | |||
raise click.BadArgumentUsage('Please provide path to setup.py') |
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 message could be misleading. We don’t want a path to setup.py, but to the directory containing it. I would use something like “path to editable package (e.g. the directory containing setup.py)” instead.
pipenv/core.py
Outdated
package_name = ' '.join([package_name, more_packages.pop(0)]) | ||
# capture indexes and extra indexes | ||
line = [package_name] + more_packages | ||
index_indicators = ['-i', '--index', '--extra-index-url'] | ||
index, extra_indexes = None, None | ||
if more_packages and any(more_packages[0].startswith(s) for s in index_indicators): | ||
if len(more_packages) < 2: | ||
raise click.BadArgumentUsage('Please provide index value') |
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 feel the logic in this block can be rewritten a bit to make the checks clearer. Right now the various checks are a bit convoluted, and require a lot of context to be understood. Why does it use more_packages
here, but package_names
below? How do they relate to line
?
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.
@uranusjr I agree with you about some extra context what you should keep in mind. I'll try to rewrite this block.
Quick refactor for improve readability of code
@uranusjr fixes according to your comments. |
CI is complaining… (the refactor look legit in general to me, just need more careful argument checking) |
8118ce1
to
7516ead
Compare
@uranusjr CI passed |
Weeeeeee We’re in code freeze mode right now (release immenent) so this will need to wait a while to be merged, but it will be in the next version! |
I pulled this branch and added a test to it and merged it, thanks a bunch for putting this together! Closed via beb6aef |
Add extra checks for CLI params for preventing unexpected crashes and add the more informal message for that exceptions.
To reproduce those bugs type following command in the terminal.