From 5a55043d757e65c5b5eaa3adeaf219ed2f9db80d Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 24 Oct 2018 16:21:04 -0400 Subject: [PATCH 1/2] Update flake8 from 3.5.0 to 3.6.0 --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index a194d2c..1fc7f67 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -r requirements.txt -flake8==3.5.0 +flake8==3.6.0 pytest==3.8.2 pytest-cov==2.6.0 From 1c81626b89d13e456002ed6ad65a368759a69548 Mon Sep 17 00:00:00 2001 From: Rehan Dalal Date: Fri, 2 Nov 2018 10:28:02 -0400 Subject: [PATCH 2/2] Fix issues --- tests/test_cli.py | 62 +++++++++++++++++------------------ therapist/cli.py | 8 ++--- therapist/utils/git/status.py | 2 +- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0a37e77..77fa184 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -302,7 +302,7 @@ def test_run(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run) - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -319,7 +319,7 @@ def test_fails(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -329,7 +329,7 @@ def test_action(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['-a', 'lint']) - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -340,8 +340,8 @@ def test_action_with_fix(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['-a', 'lint', '--fix']) - assert re.search('Linting.+?\[SUCCESS]', result.output) - assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) assert not result.exception assert result.exit_code == 0 assert project.read('pass.py') == 'FIXED' @@ -354,8 +354,8 @@ def test_action_stage_modified_files(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['-a', 'lint', '--fix', '--stage-modified-files']) - assert re.search('Linting.+?\[SUCCESS]', result.output) - assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) assert not result.exception assert result.exit_code == 0 assert project.read('pass.py') == 'FIXED' @@ -367,7 +367,7 @@ def test_action_fails(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['-a', 'lint']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -398,7 +398,7 @@ def test_plugin(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['-p', 'simple']) - assert re.search('simple.+?\[SUCCESS]', result.output) + assert re.search(r'simple.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -408,7 +408,7 @@ def test_plugin_fails(self, cli_runner, project, mock_plugin): with chdir(project.path): result = cli_runner.invoke(cli.run, ['-p', 'simple']) - assert re.search('simple.+?\[FAILURE]', result.output) + assert re.search(r'simple.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -429,7 +429,7 @@ def test_on_file(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['pass.py']) - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -439,7 +439,7 @@ def test_on_file_fail(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['fail.py']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -449,7 +449,7 @@ def test_dir(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['dir']) - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -459,7 +459,7 @@ def test_dir_fail(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['dir']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -469,7 +469,7 @@ def test_file(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['pass.py']) - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -479,7 +479,7 @@ def test_file_fail(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['fail.py']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -492,7 +492,7 @@ def test_include_untracked(self, cli_runner, project): assert result.exit_code == 0 result = cli_runner.invoke(cli.run, ['--include-untracked']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -508,7 +508,7 @@ def test_include_unstaged(self, cli_runner, project): assert result.exit_code == 0 result = cli_runner.invoke(cli.run, ['--include-unstaged']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -520,7 +520,7 @@ def test_unstaged_changes(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run) assert 'You have unstaged changes.' in result.output - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 assert project.read('pass.py') == 'x' @@ -533,7 +533,7 @@ def test_include_unstaged_changes(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['--include-unstaged-changes']) assert 'You have unstaged changes.' in result.output - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 assert project.read('pass.py') == 'x' @@ -545,7 +545,7 @@ def test_use_tracked_files(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['--use-tracked-files']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -558,7 +558,7 @@ def test_use_tracked_files_include_untracked(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['--use-tracked-files', '--include-untracked']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 @@ -605,7 +605,7 @@ def test_junit_xml(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run, ['--junit-xml=junit.xml']) - assert re.search('Linting.+?\[FAILURE]', result.output) + assert re.search(r'Linting.+?\[FAILURE]', result.output) assert result.exception assert result.exit_code == 2 assert project.exists('junit.xml') @@ -620,7 +620,7 @@ def test_errors(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.run) - assert re.search('Linting.+?\[ERROR!!]', result.output) + assert re.search(r'Linting.+?\[ERROR!!]', result.output) assert result.exception assert result.exit_code == 1 @@ -640,7 +640,7 @@ def test_use_shortcut(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.use, ['lint']) assert '$ therapist run --action lint --include-untracked' in result.output - assert re.search('Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) assert not result.exception assert result.exit_code == 0 @@ -652,8 +652,8 @@ def test_use_extended_shortcut(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.use, ['fix']) assert '$ therapist run --action lint --fix --include-untracked' in result.output - assert re.search('Linting.+?\[SUCCESS]', result.output) - assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) assert not result.exception assert result.exit_code == 0 assert project.read('pass.py') == 'FIXED' @@ -667,8 +667,8 @@ def test_extend_extended_shortcut(self, cli_runner, project): with chdir(project.path): result = cli_runner.invoke(cli.use, ['fix:all']) assert '$ therapist run --action lint --fix --include-untracked --use-tracked-files' in result.output - assert re.search('Linting.+?\[SUCCESS]', result.output) - assert re.search('Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) + assert re.search(r'Linting.+?\[SUCCESS]', result.output) + assert re.search(r'Modified files:.+?pass.py.+?<- Linting', result.output, flags=re.DOTALL) assert not result.exception assert result.exit_code == 0 assert project.read('pass.py') == 'FIXED' @@ -783,7 +783,7 @@ def test_hook_with_fix(self, cli_runner, project): project.git.add('.') out, err, code = project.git.commit(m='Add a file.') - assert re.search('Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL) + assert re.search(r'Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL) assert '[SUCCESS]' in err out, err, code = project.git.status(porcelain=True) @@ -804,7 +804,7 @@ def test_hook_with_fix_without_stage_modified_files(self, cli_runner, project): project.git.add('.') out, err, code = project.git.commit(m='Add a file.') - assert re.search('Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL) + assert re.search(r'Modified files:.+?pass.py.+?<- Linting', err, flags=re.DOTALL) assert '[SUCCESS]' in err out, err, code = project.git.status(porcelain=True) diff --git a/therapist/cli.py b/therapist/cli.py index 7009c03..e64cc6d 100644 --- a/therapist/cli.py +++ b/therapist/cli.py @@ -263,8 +263,8 @@ def run(**kwargs): if plugin: try: processes = [config.plugins.get(plugin)] - except config.plugins.DoesNotExist as err: - output('{}\nAvailable plugins:'.format(err.message)) + except config.plugins.DoesNotExist as e: + output('{}\nAvailable plugins:'.format(e.message)) for p in config.plugins: output(p.name) @@ -273,8 +273,8 @@ def run(**kwargs): if action: try: processes = [config.actions.get(action)] - except config.actions.DoesNotExist as err: - output('{}\nAvailable actions:'.format(err.message)) + except config.actions.DoesNotExist as e: + output('{}\nAvailable actions:'.format(e.message)) for a in config.actions: output(a.name) diff --git a/therapist/utils/git/status.py b/therapist/utils/git/status.py index 55f75d7..ee23d38 100644 --- a/therapist/utils/git/status.py +++ b/therapist/utils/git/status.py @@ -7,7 +7,7 @@ def __init__(self, status): self.is_modified = status[1] == 'M' if self.is_renamed: - matches = re.search('(\S+?)\s+->\s+(\S+?)$', status[3:]) + matches = re.search(r'(\S+?)\s+->\s+(\S+?)$', status[3:]) self.original_path = matches.groups()[0] self.path = matches.groups()[1] else: