8000 TST: Added script to enforce usage of match argument for tm.assert_produces_warning by chaarvii · Pull Request #59173 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: Added script to enforce usage of match argument for tm.assert_produces_warning #59173

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

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
as per reviews
  • Loading branch information
chaarvii committed Jul 4, 2024
commit 1bfe27ec55ee1ba80cfa3df6cf3aed50f2314759
10 changes: 6 additions & 4 deletions scripts/enforce_match_arg_in_assert_produces_warning.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""

Enforce that all usages of tm.assert_produces_warning use
the "match" argument. This will help ensure that users always see
the correct warning message.
Expand All @@ -8,6 +7,9 @@
and tm.assert_produces_warning(False) are excluded as no warning is
produced.

This is meant to be run as a pre-commit hook - to run it manually, you can do:

pre-commit run enforce-match-arg-in-assert-produces-warning --all-files
"""


Expand Down Expand Up @@ -68,14 +70,14 @@ def main(argv: Sequence[str] | None = None) -> None:
parser.add_argument("paths", nargs="*")

args = parser.parse_args(argv)
isMatchMissing = False
is_match_missing = False

for filename in args.paths:
with open(filename, encoding="utf-8") as fd:
content = fd.read()
isMatchMissing = check_for_match_arg(content, filename) | isMatchMissing
is 4F55 _match_missing = check_for_match_arg(content, filename) | is_match_missing

if isMatchMissing:
if is_match_missing:
sys.exit(1)


Expand Down
0