Skip to content

STY: Check pytest.raises is used context manager #24332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ 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"

# 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 (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"
Expand Down