-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add rule for pip_install permission fix #895
Conversation
The rule looks good, thanks! Can you please fix linter warnings?
|
Thanks for the contribution, @IngaFeick! I'd recommend spending some time configuring your editor to do things like strip trailing whitespaces, standardise indentation, lint the source code, etc. |
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.
Can you please change all occurrences of "
to '
? For sake of consistency :-)
thefuck/rules/pip_install.py
Outdated
def get_new_command(command): | ||
if "--user" not in command.script: # add --user (attempt 1) | ||
return command.script.replace(" install ", " install --user ") | ||
else: # since --user didn't fix things, let's try sudo (attempt 2) |
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 else here is unnecessary and should be removed.
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.
Quotation has been changed as requested.
Could you kindly explain why the else
is unnecessary? The script is supposed to react differently, depending on whether or not the command already included the --user
flag, in which case sudo might fix the issue.
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.
An else after a return is unnecessary and only increases indentation, decreasing readability.
This:
if condition:
return foo
else:
return bar
Is equivalent to this:
if condition:
return foo
return bar
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.
🤦🏻♀️ you're absolutely right of course. I thought you asked me to delete the entire else
block including the 2nd return statement.
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.
Changed as requested
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.
Oh, pardon me for not being clear about that
Looks good, thanks! |
Great, thanks! |
* Add rule for pip_install permission fix * Fix whitespace * Switch quotation to single * remove 2nd else * E261 indent comment
This PR reacts to
pip install
permission issues by either adding--user
to the command, or, if--user
is already in the command, removing the--user
flag and running the command with sudo.