From f88ebd2ea3da9fdc6fa89be3306295acc619d115 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Tue, 18 Dec 2018 03:08:35 -0800 Subject: [PATCH 1/2] STY: Check pytest.raises is used context manager Follow-up to gh-24297. --- ci/code_checks.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index ac92cf492b91d..094c23c765d29 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -151,6 +151,14 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG invgrep --exclude="*.svg" -RI "\s$" * RET=$(($RET + $?)) ; echo $MSG "DONE" + + # Check that we use pytest.raises only as a context manager + # + # For any flake8-compliant code, the only way this regex gets + # matched is if there is no "with" statement preceding "pytest.raises" + MSG='Check for pytest.raises as context manager' ; echo $MSG + invgrep -R --include '*.py' -E '[[:space:]] pytest.raises' pandas/tests + RET=$(($RET + $?)) ; echo $MSG "DONE" fi ### CODE ### From 33a427a295e9da6977d33e89e5449fbbb3a288be Mon Sep 17 00:00:00 2001 From: gfyoung Date: Tue, 18 Dec 2018 17:58:44 -0800 Subject: [PATCH 2/2] Comment about check and address comments --- ci/code_checks.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 094c23c765d29..028a9c71a0d2d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -148,16 +148,17 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then invgrep -R --exclude=*.pyc --exclude=testing.py --exclude=test_testing.py assert_raises_regex pandas RET=$(($RET + $?)) ; echo $MSG "DONE" - MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG - invgrep --exclude="*.svg" -RI "\s$" * - RET=$(($RET + $?)) ; echo $MSG "DONE" - # Check that we use pytest.raises only as a context manager # # For any flake8-compliant code, the only way this regex gets # matched is if there is no "with" statement preceding "pytest.raises" - MSG='Check for pytest.raises as context manager' ; echo $MSG - invgrep -R --include '*.py' -E '[[:space:]] pytest.raises' pandas/tests + MSG='Check for pytest.raises as context manager (a line starting with `pytest.raises` is invalid, needs a `with` to precede it)' ; echo $MSG + MSG='TODO: This check is currently skipped because so many files fail this. Please enable when all are corrected (xref gh-24332)' ; echo $MSG + # invgrep -R --include '*.py' -E '[[:space:]] pytest.raises' pandas/tests + # RET=$(($RET + $?)) ; echo $MSG "DONE" + + MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG + invgrep --exclude="*.svg" -RI "\s$" * RET=$(($RET + $?)) ; echo $MSG "DONE" fi