#1149: Add python_module_error rule (#1151)

This commit is contained in:
Divy Jain
2021-01-20 03:07:05 +05:30
committed by GitHub
parent 40dd65963d
commit 62dddd5821
3 changed files with 77 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import re
from thefuck.shells import shell
MISSING_MODULE = r"ModuleNotFoundError: No module named '([^']+)'"
def match(command):
return "ModuleNotFoundError: No module named '" in command.output
def get_new_command(command):
missing_module = re.findall(MISSING_MODULE, command.output)[0]
return shell.and_("pip install {}".format(missing_module), command.script)