From b24c23fe3bdbfff370530438257037e5c5485b22 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 4 Jan 2018 10:22:37 +0000 Subject: [PATCH] Lint for print statements flake8-print is a flake8 plugin that checks for `print()` statements in Python files. This should save us having to manually spot these when reviewing pull requests. The `--enable=T` flag needs to be set until this bug is fixed: https://github.com/JBKahn/flake8-print/issues/27 --- app/commands.py | 2 +- requirements_for_test.txt | 1 + scripts/run_tests.sh | 2 +- tests/__init__.py | 2 -- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/commands.py b/app/commands.py index c13dfee18..026be777a 100644 --- a/app/commands.py +++ b/app/commands.py @@ -4,7 +4,7 @@ from flask import current_app def list_routes(): """List URLs of all application routes.""" for rule in sorted(current_app.url_map.iter_rules(), key=lambda r: r.rule): - print("{:10} {}".format(", ".join(rule.methods - set(['OPTIONS', 'HEAD'])), rule.rule)) + print("{:10} {}".format(", ".join(rule.methods - set(['OPTIONS', 'HEAD'])), rule.rule)) # noqa def setup_commands(application): diff --git a/requirements_for_test.txt b/requirements_for_test.txt index b3196465e..a1da983f3 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -8,3 +8,4 @@ httpretty==0.8.14 beautifulsoup4==4.6.0 freezegun==0.3.9 flake8==3.5.0 +flake8-print==3.0.1 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index d8d6b5a39..2b5da0565 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -28,7 +28,7 @@ if [[ -z "$VIRTUAL_ENV" ]] && [[ -d venv ]]; then source ./venv/bin/activate fi -flake8 . +flake8 --enable=T . display_result $? 1 "Code style check" npm test diff --git a/tests/__init__.py b/tests/__init__.py index 262b008e5..b5ba0350d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -368,7 +368,6 @@ def validate_route_permission(mocker, else: pytest.fail("Invalid method call {}".format(method)) if resp.status_code != response_code: - print(resp.status_code) pytest.fail("Invalid permissions set for endpoint {}".format(route)) return resp @@ -403,6 +402,5 @@ def validate_route_permission_with_client(mocker, else: pytest.fail("Invalid method call {}".format(method)) if resp.status_code != response_code: - print(resp.status_code) pytest.fail("Invalid permissions set for endpoint {}".format(route)) return resp