From c7d7a6d1d70ac48c1d1b5dee252fbcccb4bd8e3d Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Mon, 13 Mar 2017 13:30:07 +0100 Subject: [PATCH] #612: Little cleanup --- tests/rules/test_yarn_help.py | 3 ++- thefuck/rules/yarn_help.py | 7 +++++-- thefuck/system/unix.py | 2 +- thefuck/system/win32.py | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/rules/test_yarn_help.py b/tests/rules/test_yarn_help.py index 4bb06b2..18a607f 100644 --- a/tests/rules/test_yarn_help.py +++ b/tests/rules/test_yarn_help.py @@ -51,6 +51,7 @@ def test_match(command): @pytest.mark.parametrize('command, new_command', [ - (Command('yarn help clean', stdout=stdout_clean), open_command('https://yarnpkg.com/en/docs/cli/clean'))]) + (Command('yarn help clean', stdout=stdout_clean), + open_command('https://yarnpkg.com/en/docs/cli/clean'))]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command diff --git a/thefuck/rules/yarn_help.py b/thefuck/rules/yarn_help.py index 3902eb5..a4d8f93 100644 --- a/thefuck/rules/yarn_help.py +++ b/thefuck/rules/yarn_help.py @@ -5,10 +5,13 @@ from thefuck.system import open_command @for_app('yarn', at_least=2) def match(command): - return command.script_parts[1] == 'help' and ('for documentation about this command.' in command.stdout) + return (command.script_parts[1] == 'help' + and 'for documentation about this command.' in command.stdout) def get_new_command(command): - url = re.findall(r'Visit ([^ ]*) for documentation about this command.', command.stdout)[0] + url = re.findall( + r'Visit ([^ ]*) for documentation about this command.', + command.stdout)[0] return open_command(url) diff --git a/thefuck/system/unix.py b/thefuck/system/unix.py index aac2532..0a29bb6 100644 --- a/thefuck/system/unix.py +++ b/thefuck/system/unix.py @@ -38,7 +38,7 @@ def get_key(): def open_command(arg): - if (find_executable('xdg-open')): + if find_executable('xdg-open'): return 'xdg-open ' + arg return 'open ' + arg diff --git a/thefuck/system/win32.py b/thefuck/system/win32.py index 2851498..ce649a4 100644 --- a/thefuck/system/win32.py +++ b/thefuck/system/win32.py @@ -23,7 +23,8 @@ def get_key(): if ch == b'P': return const.KEY_DOWN - encoding = sys.stdout.encoding or os.environ.get('PYTHONIOENCODING', 'utf-8') + encoding = (sys.stdout.encoding + or os.environ.get('PYTHONIOENCODING', 'utf-8')) return ch.decode(encoding)