mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Fix some pep8 issues, mostly spaces
Before: 4 E101 indentation contains mixed spaces and tabs 20 E122 continuation line missing indentation or outdented 1 E124 closing bracket does not match visual indentation 12 E127 continuation line over-indented for visual indent 22 E128 continuation line under-indented for visual indent 2 E211 whitespace before '(' 12 E302 expected 2 blank lines, found 1 1 E303 too many blank lines (3) 4 E402 module level import not at top of file 123 E501 line too long (81 > 79 characters) 2 E731 do not assign a lambda expression, use a def 3 W191 indentation contains tabs 20 W291 trailing whitespace 3 W293 blank line contains whitespace 2 W391 blank line at end of file 69 W503 line break before binary operator After: 20 E122 continuation line missing indentation or outdented 12 E127 continuation line over-indented for visual indent 22 E128 continuation line under-indented for visual indent 123 E501 line too long (81 > 79 characters) 2 E731 do not assign a lambda expression, use a def 1 W291 trailing whitespace 68 W503 line break before binary operator
This commit is contained in:
parent
85647794dc
commit
7f0f9a966f
@ -5,34 +5,38 @@ from tests.utils import Command
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def composer_not_command():
|
def composer_not_command():
|
||||||
return """
|
# that weird spacing is part of the actual command output
|
||||||
|
return (
|
||||||
|
'\n'
|
||||||
[InvalidArgumentException]
|
'\n'
|
||||||
Command "udpate" is not defined.
|
' \n'
|
||||||
Did you mean this?
|
' [InvalidArgumentException] \n'
|
||||||
update
|
' Command "udpate" is not defined. \n'
|
||||||
|
' Did you mean this? \n'
|
||||||
|
' update \n'
|
||||||
"""
|
' \n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def composer_not_command_one_of_this():
|
def composer_not_command_one_of_this():
|
||||||
return """
|
# that weird spacing is part of the actual command output
|
||||||
|
return (
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
[InvalidArgumentException]
|
' \n'
|
||||||
Command "pdate" is not defined.
|
' [InvalidArgumentException] \n'
|
||||||
Did you mean one of these?
|
' Command "pdate" is not defined. \n'
|
||||||
selfupdate
|
' Did you mean one of these? \n'
|
||||||
self-update
|
' selfupdate \n'
|
||||||
update
|
' self-update \n'
|
||||||
|
' update \n'
|
||||||
|
' \n'
|
||||||
|
'\n'
|
||||||
"""
|
'\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_match(composer_not_command, composer_not_command_one_of_this):
|
def test_match(composer_not_command, composer_not_command_one_of_this):
|
||||||
|
@ -40,6 +40,7 @@ parametrize_script = pytest.mark.parametrize('script, fixed', [
|
|||||||
('tar -xvf {}', 'mkdir -p foo && tar -xvf {} -C foo'),
|
('tar -xvf {}', 'mkdir -p foo && tar -xvf {} -C foo'),
|
||||||
('tar --extract -f {}', 'mkdir -p foo && tar --extract -f {} -C foo')])
|
('tar --extract -f {}', 'mkdir -p foo && tar --extract -f {} -C foo')])
|
||||||
|
|
||||||
|
|
||||||
@parametrize_filename
|
@parametrize_filename
|
||||||
@parametrize_script
|
@parametrize_script
|
||||||
def test_match(tar_error, filename, script, fixed):
|
def test_match(tar_error, filename, script, fixed):
|
||||||
|
@ -85,8 +85,7 @@ Traceback (most recent call last):
|
|||||||
File "/usr/lib/python3.4/re.py", line 293, in _compile
|
File "/usr/lib/python3.4/re.py", line 293, in _compile
|
||||||
raise TypeError("first argument must be string or compiled pattern")
|
raise TypeError("first argument must be string or compiled pattern")
|
||||||
TypeError: first argument must be string or compiled pattern
|
TypeError: first argument must be string or compiled pattern
|
||||||
"""
|
"""),
|
||||||
),
|
|
||||||
|
|
||||||
('ruby a.rb', 'a.rb', 3, None,
|
('ruby a.rb', 'a.rb', 3, None,
|
||||||
"""
|
"""
|
||||||
|
@ -2,6 +2,7 @@ from thefuck import shells
|
|||||||
from thefuck.rules.git_branch_list import match, get_new_command
|
from thefuck.rules.git_branch_list import match, get_new_command
|
||||||
from tests.utils import Command
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
def test_match():
|
def test_match():
|
||||||
assert match(Command('git branch list'), None)
|
assert match(Command('git branch list'), None)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ usage: git stash list [<options>]
|
|||||||
or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
|
or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
|
||||||
or: git stash branch <branchname> [<stash>]
|
or: git stash branch <branchname> [<stash>]
|
||||||
or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
|
or: git stash [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
|
||||||
[-u|--include-untracked] [-a|--all] [<message>]]
|
\t\t [-u|--include-untracked] [-a|--all] [<message>]]
|
||||||
or: git stash clear
|
or: git stash clear
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ def git_not_command_closest():
|
|||||||
return '''git: 'tags' is not a git command. See 'git --help'.
|
return '''git: 'tags' is not a git command. See 'git --help'.
|
||||||
|
|
||||||
Did you mean one of these?
|
Did you mean one of these?
|
||||||
stage
|
\tstage
|
||||||
tag
|
\ttag
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from tests.utils import Command
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('command', [
|
||||||
Command(script='go run foo'),
|
Command(script='go run foo'),
|
||||||
Command(script='go run bar')])
|
Command(script='go run bar')])
|
||||||
def test_match(command):
|
def test_match(command):
|
||||||
assert match(command, None)
|
assert match(command, None)
|
||||||
|
@ -3,7 +3,6 @@ from thefuck.rules.systemctl import match, get_new_command
|
|||||||
from tests.utils import Command
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_match():
|
def test_match():
|
||||||
assert match(Command('systemctl nginx start', stderr='Unknown operation \'nginx\'.'), None)
|
assert match(Command('systemctl nginx start', stderr='Unknown operation \'nginx\'.'), None)
|
||||||
assert match(Command('sudo systemctl nginx start', stderr='Unknown operation \'nginx\'.'), None)
|
assert match(Command('sudo systemctl nginx start', stderr='Unknown operation \'nginx\'.'), None)
|
||||||
@ -13,6 +12,7 @@ def test_match():
|
|||||||
assert not match(Command('systemctl nginx', stderr='Unknown operation \'nginx\'.'), None)
|
assert not match(Command('systemctl nginx', stderr='Unknown operation \'nginx\'.'), None)
|
||||||
assert not match(Command('systemctl start wtf', stderr='Failed to start wtf.service: Unit wtf.service failed to load: No such file or directory.'), None)
|
assert not match(Command('systemctl start wtf', stderr='Failed to start wtf.service: Unit wtf.service failed to load: No such file or directory.'), None)
|
||||||
|
|
||||||
|
|
||||||
def test_get_new_command():
|
def test_get_new_command():
|
||||||
assert get_new_command(Command('systemctl nginx start'), None) == "systemctl start nginx"
|
assert get_new_command(Command('systemctl nginx start'), None) == "systemctl start nginx"
|
||||||
assert get_new_command(Command('sudo systemctl nginx start'), None) == "sudo systemctl start nginx"
|
assert get_new_command(Command('sudo systemctl nginx start'), None) == "sudo systemctl start nginx"
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# Appends --all to the brew upgrade command
|
# Appends --all to the brew upgrade command
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# > brew upgrade
|
# > brew upgrade
|
||||||
# Warning: brew upgrade with no arguments will change behaviour soon!
|
# Warning: brew upgrade with no arguments will change behaviour soon!
|
||||||
# It currently upgrades all formula but this will soon change to require '--all'.
|
# It currently upgrades all formula but this will soon change to require '--all'.
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return (command.script == 'brew upgrade')
|
return command.script == 'brew upgrade'
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return command.script + ' --all'
|
return command.script + ' --all'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
__author__ = "mmussomele"
|
|
||||||
|
|
||||||
"""Attempts to spellcheck and correct failed cd commands"""
|
"""Attempts to spellcheck and correct failed cd commands"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -8,6 +5,8 @@ from difflib import get_close_matches
|
|||||||
from thefuck.utils import sudo_support
|
from thefuck.utils import sudo_support
|
||||||
from thefuck.rules import cd_mkdir
|
from thefuck.rules import cd_mkdir
|
||||||
|
|
||||||
|
__author__ = "mmussomele"
|
||||||
|
|
||||||
MAX_ALLOWED_DIFF = 0.6
|
MAX_ALLOWED_DIFF = 0.6
|
||||||
|
|
||||||
|
|
||||||
@ -28,8 +27,8 @@ def match(command, settings):
|
|||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
"""
|
"""
|
||||||
Attempt to rebuild the path string by spellchecking the directories.
|
Attempt to rebuild the path string by spellchecking the directories.
|
||||||
If it fails (i.e. no directories are a close enough match), then it
|
If it fails (i.e. no directories are a close enough match), then it
|
||||||
defaults to the rules of cd_mkdir.
|
defaults to the rules of cd_mkdir.
|
||||||
Change sensitivity by changing MAX_ALLOWED_DIFF. Default value is 0.6
|
Change sensitivity by changing MAX_ALLOWED_DIFF. Default value is 0.6
|
||||||
"""
|
"""
|
||||||
dest = command.script.split()[1].split(os.sep)
|
dest = command.script.split()[1].split(os.sep)
|
||||||
|
@ -7,8 +7,10 @@
|
|||||||
# > cd..
|
# > cd..
|
||||||
# cd..: command not found
|
# cd..: command not found
|
||||||
|
|
||||||
|
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return command.script == 'cd..'
|
return command.script == 'cd..'
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return 'cd ..'
|
return 'cd ..'
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# Appends .go when compiling go files
|
# Appends .go when compiling go files
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# > go run foo
|
# > go run foo
|
||||||
# error: go run: no go files listed
|
# error: go run: no go files listed
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return (command.script.startswith ('go run ')
|
return (command.script.startswith('go run ')
|
||||||
and not command.script.endswith('.go'))
|
and not command.script.endswith('.go'))
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return command.script + '.go'
|
return command.script + '.go'
|
||||||
|
@ -11,4 +11,3 @@ def match(command, settings):
|
|||||||
@sudo_support
|
@sudo_support
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return u'./{}'.format(command.script)
|
return u'./{}'.format(command.script)
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ def _history_of_exists_without_current(command):
|
|||||||
if not line.startswith(tf_alias) and not line == command.script
|
if not line.startswith(tf_alias) and not line == command.script
|
||||||
and line.split(' ')[0] in executables]
|
and line.split(' ')[0] in executables]
|
||||||
|
|
||||||
|
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return len(get_close_matches(command.script,
|
return len(get_close_matches(command.script,
|
||||||
_history_of_exists_without_current(command)))
|
_history_of_exists_without_current(command)))
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# > javac foo
|
# > javac foo
|
||||||
# error: Class names, 'foo', are only accepted if annotation
|
# error: Class names, 'foo', are only accepted if annotation
|
||||||
# processing is explicitly requested
|
# processing is explicitly requested
|
||||||
|
|
||||||
|
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return (command.script.startswith('javac ')
|
return (command.script.startswith('javac ')
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
# Fixes careless " and ' usage
|
# Fixes careless " and ' usage
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# > git commit -m 'My Message"
|
# > git commit -m 'My Message"
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
def match(command, settings):
|
def match(command, settings):
|
||||||
return ('\'' in command.script
|
return '\'' in command.script and '\"' in command.script
|
||||||
and '\"' in command.script)
|
|
||||||
|
|
||||||
def get_new_command(command, settings):
|
def get_new_command(command, settings):
|
||||||
return command.script.replace ('\'', '\"')
|
return command.script.replace('\'', '\"')
|
||||||
|
@ -14,4 +14,3 @@ def get_new_command(command, settings):
|
|||||||
command.stderr)[0]
|
command.stderr)[0]
|
||||||
return replace_command(command, broken_cmd,
|
return replace_command(command, broken_cmd,
|
||||||
get_all_matched_commands(command.stderr))
|
get_all_matched_commands(command.stderr))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user