mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-19 17:20:39 +01:00
Fix some pep8 warnings
This commit is contained in:
parent
c3ea2fd0c7
commit
8feb722ed0
@ -63,6 +63,7 @@ def test_side_effect(ext, tar_error, filename, unquoted, quoted, script, fixed):
|
|||||||
side_effect(Command(script=script.format(filename.format(ext))), None)
|
side_effect(Command(script=script.format(filename.format(ext))), None)
|
||||||
assert set(os.listdir('.')) == {unquoted.format(ext), 'd'}
|
assert set(os.listdir('.')) == {unquoted.format(ext), 'd'}
|
||||||
|
|
||||||
|
|
||||||
@parametrize_extensions
|
@parametrize_extensions
|
||||||
@parametrize_filename
|
@parametrize_filename
|
||||||
@parametrize_script
|
@parametrize_script
|
||||||
|
@ -7,7 +7,7 @@ from tests.utils import Command
|
|||||||
Command('mkdir foo/bar/baz', stderr='mkdir: foo/bar: No such file or directory'),
|
Command('mkdir foo/bar/baz', stderr='mkdir: foo/bar: No such file or directory'),
|
||||||
Command('./bin/hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory'),
|
Command('./bin/hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory'),
|
||||||
Command('hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory')
|
Command('hdfs dfs -mkdir foo/bar/baz', stderr='mkdir: `foo/bar/baz\': No such file or directory')
|
||||||
])
|
])
|
||||||
def test_match(command):
|
def test_match(command):
|
||||||
assert match(command)
|
assert match(command)
|
||||||
|
|
||||||
@ -17,7 +17,8 @@ def test_match(command):
|
|||||||
Command('mkdir foo/bar/baz', stderr='foo bar baz'),
|
Command('mkdir foo/bar/baz', stderr='foo bar baz'),
|
||||||
Command('hdfs dfs -mkdir foo/bar/baz'),
|
Command('hdfs dfs -mkdir foo/bar/baz'),
|
||||||
Command('./bin/hdfs dfs -mkdir foo/bar/baz'),
|
Command('./bin/hdfs dfs -mkdir foo/bar/baz'),
|
||||||
Command()])
|
Command(),
|
||||||
|
])
|
||||||
def test_not_match(command):
|
def test_not_match(command):
|
||||||
assert not match(command)
|
assert not match(command)
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ def test_not_match(command):
|
|||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
(Command('mkdir foo/bar/baz'), 'mkdir -p foo/bar/baz'),
|
(Command('mkdir foo/bar/baz'), 'mkdir -p foo/bar/baz'),
|
||||||
(Command('hdfs dfs -mkdir foo/bar/baz'), 'hdfs dfs -mkdir -p foo/bar/baz'),
|
(Command('hdfs dfs -mkdir foo/bar/baz'), 'hdfs dfs -mkdir -p foo/bar/baz'),
|
||||||
(Command('./bin/hdfs dfs -mkdir foo/bar/baz'), './bin/hdfs dfs -mkdir -p foo/bar/baz')])
|
(Command('./bin/hdfs dfs -mkdir foo/bar/baz'), './bin/hdfs dfs -mkdir -p foo/bar/baz'),
|
||||||
|
])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ def test_match(command):
|
|||||||
def test_not_match(command):
|
def test_not_match(command):
|
||||||
assert not match(command)
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
(Command(script='mvn', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean package', 'mvn clean install']),
|
(Command(script='mvn', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean package', 'mvn clean install']),
|
||||||
(Command(script='mvn -N', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn -N clean package', 'mvn -N clean install'])])
|
(Command(script='mvn -N', stdout='[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn -N clean package', 'mvn -N clean install'])])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ def test_match(command):
|
|||||||
def test_not_match(command):
|
def test_not_match(command):
|
||||||
assert not match(command)
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
(Command(script='mvn cle', stdout='[ERROR] Unknown lifecycle phase "cle". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean', 'mvn compile']),
|
(Command(script='mvn cle', stdout='[ERROR] Unknown lifecycle phase "cle". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean', 'mvn compile']),
|
||||||
(Command(script='mvn claen package', stdout='[ERROR] Unknown lifecycle phase "claen". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean package'])])
|
(Command(script='mvn claen package', stdout='[ERROR] Unknown lifecycle phase "claen". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]'), ['mvn clean package'])])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from tests.utils import Command
|
|||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('command', [
|
||||||
Command(script='mv foo bar/foo', stderr="mv: cannot move 'foo' to 'bar/foo': No such file or directory"),
|
Command(script='mv foo bar/foo', stderr="mv: cannot move 'foo' to 'bar/foo': No such file or directory"),
|
||||||
Command(script='mv foo bar/', stderr="mv: cannot move 'foo' to 'bar/': No such file or directory"),
|
Command(script='mv foo bar/', stderr="mv: cannot move 'foo' to 'bar/': No such file or directory"),
|
||||||
])
|
])
|
||||||
def test_match(command):
|
def test_match(command):
|
||||||
assert match(command)
|
assert match(command)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ def test_match(command):
|
|||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('command', [
|
||||||
Command(script='mv foo bar/', stderr=""),
|
Command(script='mv foo bar/', stderr=""),
|
||||||
Command(script='mv foo bar/foo', stderr="mv: permission denied"),
|
Command(script='mv foo bar/foo', stderr="mv: permission denied"),
|
||||||
])
|
])
|
||||||
def test_not_match(command):
|
def test_not_match(command):
|
||||||
assert not match(command)
|
assert not match(command)
|
||||||
|
|
||||||
@ -22,6 +22,6 @@ def test_not_match(command):
|
|||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
(Command(script='mv foo bar/foo', stderr="mv: cannot move 'foo' to 'bar/foo': No such file or directory"), 'mkdir -p bar && mv foo bar/foo'),
|
(Command(script='mv foo bar/foo', stderr="mv: cannot move 'foo' to 'bar/foo': No such file or directory"), 'mkdir -p bar && mv foo bar/foo'),
|
||||||
(Command(script='mv foo bar/', stderr="mv: cannot move 'foo' to 'bar/': No such file or directory"), 'mkdir -p bar && mv foo bar/'),
|
(Command(script='mv foo bar/', stderr="mv: cannot move 'foo' to 'bar/': No such file or directory"), 'mkdir -p bar && mv foo bar/'),
|
||||||
])
|
])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
@ -7,8 +7,8 @@ from tests.utils import Command
|
|||||||
Command('rm foo', stderr='rm: foo: is a directory'),
|
Command('rm foo', stderr='rm: foo: is a directory'),
|
||||||
Command('rm foo', stderr='rm: foo: Is a directory'),
|
Command('rm foo', stderr='rm: foo: Is a directory'),
|
||||||
Command('hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
|
Command('hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
|
||||||
Command('./bin/hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory')
|
Command('./bin/hdfs dfs -rm foo', stderr='rm: `foo`: Is a directory'),
|
||||||
])
|
])
|
||||||
def test_match(command):
|
def test_match(command):
|
||||||
assert match(command)
|
assert match(command)
|
||||||
|
|
||||||
@ -17,15 +17,15 @@ def test_match(command):
|
|||||||
Command('rm foo'),
|
Command('rm foo'),
|
||||||
Command('hdfs dfs -rm foo'),
|
Command('hdfs dfs -rm foo'),
|
||||||
Command('./bin/hdfs dfs -rm foo'),
|
Command('./bin/hdfs dfs -rm foo'),
|
||||||
Command()])
|
Command(),
|
||||||
|
])
|
||||||
def test_not_match(command):
|
def test_not_match(command):
|
||||||
assert not match(command)
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
(Command('rm foo'), 'rm -rf foo'),
|
(Command('rm foo'), 'rm -rf foo'),
|
||||||
(Command('hdfs dfs -rm foo'), 'hdfs dfs -rm -r foo')])
|
(Command('hdfs dfs -rm foo'), 'hdfs dfs -rm -r foo'),
|
||||||
|
])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,4 +32,3 @@ def test_not_match(command):
|
|||||||
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'), ['./bin/hdfs dfs -Dtest=fred -ls -R /foo/bar'])])
|
stderr='ls: Unknown command\nDid you mean -ls? This command begins with a dash.'), ['./bin/hdfs dfs -Dtest=fred -ls -R /foo/bar'])])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
|
||||||
|
@ -32,4 +32,3 @@ def test_not_match(command):
|
|||||||
stderr='VM must be created before running this command. Run `vagrant up` first.'), ['vagrant up devbox && vagrant rdp devbox', 'vagrant up && vagrant rdp devbox'])])
|
stderr='VM must be created before running this command. Run `vagrant up` first.'), ['vagrant up devbox && vagrant rdp devbox', 'vagrant up && vagrant rdp devbox'])])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(command, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(command) == new_command
|
||||||
|
|
||||||
|
@ -122,4 +122,3 @@ class TestCommand(object):
|
|||||||
else:
|
else:
|
||||||
with pytest.raises(EmptyCommand):
|
with pytest.raises(EmptyCommand):
|
||||||
Command.from_raw_script(script)
|
Command.from_raw_script(script)
|
||||||
|
|
||||||
|
@ -7,31 +7,31 @@ from thefuck import shells
|
|||||||
|
|
||||||
# order is important: only the first match is considered
|
# order is important: only the first match is considered
|
||||||
patterns = (
|
patterns = (
|
||||||
# js, node:
|
# js, node:
|
||||||
'^ at {file}:{line}:{col}',
|
'^ at {file}:{line}:{col}',
|
||||||
# cargo:
|
# cargo:
|
||||||
'^ {file}:{line}:{col}',
|
'^ {file}:{line}:{col}',
|
||||||
# python, thefuck:
|
# python, thefuck:
|
||||||
'^ File "{file}", line {line}',
|
'^ File "{file}", line {line}',
|
||||||
# awk:
|
# awk:
|
||||||
'^awk: {file}:{line}:',
|
'^awk: {file}:{line}:',
|
||||||
# git
|
# git
|
||||||
'^fatal: bad config file line {line} in {file}',
|
'^fatal: bad config file line {line} in {file}',
|
||||||
# llc:
|
# llc:
|
||||||
'^llc: {file}:{line}:{col}:',
|
'^llc: {file}:{line}:{col}:',
|
||||||
# lua:
|
# lua:
|
||||||
'^lua: {file}:{line}:',
|
'^lua: {file}:{line}:',
|
||||||
# fish:
|
# fish:
|
||||||
'^{file} \\(line {line}\\):',
|
'^{file} \\(line {line}\\):',
|
||||||
# bash, sh, ssh:
|
# bash, sh, ssh:
|
||||||
'^{file}: line {line}: ',
|
'^{file}: line {line}: ',
|
||||||
# cargo, clang, gcc, go, pep8, rustc:
|
# cargo, clang, gcc, go, pep8, rustc:
|
||||||
'^{file}:{line}:{col}',
|
'^{file}:{line}:{col}',
|
||||||
# ghc, make, ruby, zsh:
|
# ghc, make, ruby, zsh:
|
||||||
'^{file}:{line}:',
|
'^{file}:{line}:',
|
||||||
# perl:
|
# perl:
|
||||||
'at {file} line {line}',
|
'at {file} line {line}',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# for the sake of readability do not use named groups above
|
# for the sake of readability do not use named groups above
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
from thefuck.utils import replace_command
|
from thefuck.utils import replace_command
|
||||||
|
|
||||||
|
|
||||||
def match(command):
|
def match(command):
|
||||||
return (re.search(r"([^:]*): Unknown command.*", command.stderr) != None
|
return (re.search(r"([^:]*): Unknown command.*", command.stderr) != None
|
||||||
and re.search(r"Did you mean ([^?]*)?", command.stderr) != None)
|
and re.search(r"Did you mean ([^?]*)?", command.stderr) != None)
|
||||||
@ -10,4 +11,3 @@ def get_new_command(command):
|
|||||||
broken_cmd = re.findall(r"([^:]*): Unknown command.*", command.stderr)[0]
|
broken_cmd = re.findall(r"([^:]*): Unknown command.*", command.stderr)[0]
|
||||||
matched = re.findall(r"Did you mean ([^?]*)?", command.stderr)
|
matched = re.findall(r"Did you mean ([^?]*)?", command.stderr)
|
||||||
return replace_command(command, broken_cmd, matched)
|
return replace_command(command, broken_cmd, matched)
|
||||||
|
|
||||||
|
@ -17,4 +17,4 @@ def get_new_command(command):
|
|||||||
if machine is None:
|
if machine is None:
|
||||||
return startAllInstances
|
return startAllInstances
|
||||||
else:
|
else:
|
||||||
return [ shells.and_("vagrant up " + machine, command.script), startAllInstances]
|
return [shells.and_("vagrant up " + machine, command.script), startAllInstances]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user