Merge branch 'flake8' of https://github.com/josephfrazier/thefuck into josephfrazier-flake8

# Conflicts:
#	thefuck/system/unix.py
#	thefuck/system/win32.py
This commit is contained in:
Vladimir Iakovlev
2017-03-13 13:35:11 +01:00
60 changed files with 172 additions and 173 deletions
+14 -15
View File
@@ -3,16 +3,16 @@ from .system import init_output
init_output()
from argparse import ArgumentParser
from pprint import pformat
import sys
from . import logs, types
from .shells import shell
from .conf import settings
from .corrector import get_corrected_commands
from .exceptions import EmptyCommand
from .utils import get_installation_info, get_alias
from .ui import select_command
from argparse import ArgumentParser # noqa: E402
from pprint import pformat # noqa: E402
import sys # noqa: E402
from . import logs, types # noqa: E402
from .shells import shell # noqa: E402
from .conf import settings # noqa: E402
from .corrector import get_corrected_commands # noqa: E402
from .exceptions import EmptyCommand # noqa: E402
from .utils import get_installation_info, get_alias # noqa: E402
from .ui import select_command # noqa: E402
def fix_command():
@@ -59,11 +59,10 @@ def how_to_configure_alias():
def main():
parser = ArgumentParser(prog='thefuck')
version = get_installation_info().version
parser.add_argument(
'-v', '--version',
action='version',
version='The Fuck {} using Python {}'.format(
version, sys.version.split()[0]))
parser.add_argument('-v', '--version',
action='version',
version='The Fuck {} using Python {}'.format(
version, sys.version.split()[0]))
parser.add_argument('-a', '--alias',
action='store_true',
help='[custom-alias-name] prints alias for current shell')
+2 -2
View File
@@ -54,8 +54,8 @@ def _brew_commands():
brew_path_prefix = get_brew_path_prefix()
if brew_path_prefix:
try:
return _get_brew_commands(brew_path_prefix) \
+ _get_brew_tap_specific_commands(brew_path_prefix)
return (_get_brew_commands(brew_path_prefix)
+ _get_brew_tap_specific_commands(brew_path_prefix))
except OSError:
pass
+1 -1
View File
@@ -39,7 +39,7 @@ def match(command):
def get_new_command(command):
return u'{} -d {}'.format(
command.script, shell.quote(_zip_file(command)[:-4]))
command.script, shell.quote(_zip_file(command)[:-4]))
def side_effect(old_cmd, command):
+1
View File
@@ -9,6 +9,7 @@ def match(command):
def get_new_command(command):
return ' '.join(command.script_parts[1:])
# it should be rare enough to actually have to type twice the same word, so
# this rule can have a higher priority to come before things like "cd cd foo"
priority = 900
+2
View File
@@ -40,6 +40,8 @@ def _make_pattern(pattern):
.replace('{line}', '(?P<line>[0-9]+)') \
.replace('{col}', '(?P<col>[0-9]+)')
return re.compile(pattern, re.MULTILINE)
patterns = [_make_pattern(p).search for p in patterns]
+1 -1
View File
@@ -10,4 +10,4 @@ def match(command):
@git_support
def get_new_command(command):
return replace_argument(command.script, 'add', 'add --force')
return replace_argument(command.script, 'add', 'add --force')
+1
View File
@@ -11,6 +11,7 @@ def match(command):
else:
return False
# git's output here is too complicated to be parsed (see the test file)
stash_commands = (
'apply',
@@ -6,7 +6,7 @@ from thefuck.specific.git import git_support
def match(command):
return ('pull' in command.script
and ('You have unstaged changes' in command.stderr
or 'contains uncommitted changes' in command.stderr))
or 'contains uncommitted changes' in command.stderr))
@git_support
+1 -3
View File
@@ -1,6 +1,6 @@
import subprocess
from thefuck.utils import for_app, replace_command, eager
import sys
@for_app('ifconfig')
def match(command):
@@ -21,5 +21,3 @@ def get_new_command(command):
interface = command.stderr.split(' ')[0][:-1]
possible_interfaces = _get_possible_interfaces()
return replace_command(command, interface, possible_interfaces)
+1
View File
@@ -6,4 +6,5 @@ def match(command):
def get_new_command(command):
return u'man {}'.format(command.script[3:])
priority = 2000
+1
View File
@@ -13,4 +13,5 @@ def get_new_command(command):
return [formatme.format(pacman, package, command.script)
for package in packages]
enabled_by_default, pacman = archlinux_env()
+2 -2
View File
@@ -33,8 +33,8 @@ def match(command):
if 'not found' not in command.stderr:
return False
matched_layout = _get_matched_layout(command)
return matched_layout and \
_switch_command(command, matched_layout) != get_alias()
return (matched_layout and
_switch_command(command, matched_layout) != get_alias())
def get_new_command(command):
+2 -2
View File
@@ -3,8 +3,8 @@ from thefuck.utils import replace_command
def match(command):
return (re.search(r"([^:]*): Unknown command.*", command.stderr) != None
and re.search(r"Did you mean ([^?]*)?", command.stderr) != None)
return (re.search(r"([^:]*): Unknown command.*", command.stderr) is not None
and re.search(r"Did you mean ([^?]*)?", command.stderr) is not None)
def get_new_command(command):
+2 -2
View File
@@ -26,7 +26,7 @@ def get_new_command(command):
available = _get_all_environments()
if available:
return replace_command(command, misspelled_env, available) \
+ [create_new]
return (replace_command(command, misspelled_env, available)
+ [create_new])
else:
return create_new
+3 -3
View File
@@ -19,9 +19,9 @@ class Tcsh(Generic):
def get_aliases(self):
proc = Popen(['tcsh', '-ic', 'alias'], stdout=PIPE, stderr=DEVNULL)
return dict(
self._parse_alias(alias)
for alias in proc.stdout.read().decode('utf-8').split('\n')
if alias and '\t' in alias)
self._parse_alias(alias)
for alias in proc.stdout.read().decode('utf-8').split('\n')
if alias and '\t' in alias)
def _get_history_file_name(self):
return os.environ.get("HISTFILE",
+2 -2
View File
@@ -2,6 +2,6 @@ import sys
if sys.platform == 'win32':
from .win32 import *
from .win32 import * # noqa: F401,F403
else:
from .unix import *
from .unix import * # noqa: F401,F403
+1
View File
@@ -52,5 +52,6 @@ except ImportError:
def _expanduser(self):
return self.__class__(os.path.expanduser(str(self)))
if not hasattr(Path, 'expanduser'):
Path.expanduser = _expanduser
+1
View File
@@ -41,5 +41,6 @@ except ImportError:
def _expanduser(self):
return self.__class__(os.path.expanduser(str(self)))
# pathlib's expanduser fails on windows, see http://bugs.python.org/issue19776
Path.expanduser = _expanduser
+11 -11
View File
@@ -40,8 +40,8 @@ class Command(object):
def __eq__(self, other):
if isinstance(other, Command):
return (self.script, self.stdout, self.stderr) \
== (other.script, other.stdout, other.stderr)
return ((self.script, self.stdout, self.stderr)
== (other.script, other.stdout, other.stderr))
else:
return False
@@ -159,12 +159,12 @@ class Rule(object):
def __eq__(self, other):
if isinstance(other, Rule):
return (self.name, self.match, self.get_new_command,
self.enabled_by_default, self.side_effect,
self.priority, self.requires_output) \
== (other.name, other.match, other.get_new_command,
other.enabled_by_default, other.side_effect,
other.priority, other.requires_output)
return ((self.name, self.match, self.get_new_command,
self.enabled_by_default, self.side_effect,
self.priority, self.requires_output)
== (other.name, other.match, other.get_new_command,
other.enabled_by_default, other.side_effect,
other.priority, other.requires_output))
else:
return False
@@ -172,9 +172,9 @@ class Rule(object):
return 'Rule(name={}, match={}, get_new_command={}, ' \
'enabled_by_default={}, side_effect={}, ' \
'priority={}, requires_output)'.format(
self.name, self.match, self.get_new_command,
self.enabled_by_default, self.side_effect,
self.priority, self.requires_output)
self.name, self.match, self.get_new_command,
self.enabled_by_default, self.side_effect,
self.priority, self.requires_output)
@classmethod
def from_path(cls, path):
+4
View File
@@ -40,6 +40,8 @@ def memoize(fn):
return value
return wrapper
memoize.disabled = False
@@ -238,6 +240,8 @@ def cache(*depends_on):
return value
return _cache
cache.disabled = False