Skip to content

fix flake8 build error due to missing stacklevel argument for warn method#554

Merged
imatiach-msft merged 1 commit intointerpretml:mainfrom
imatiach-msft:ilmat/fix-flake8
Mar 6, 2023
Merged

fix flake8 build error due to missing stacklevel argument for warn method#554
imatiach-msft merged 1 commit intointerpretml:mainfrom
imatiach-msft:ilmat/fix-flake8

Conversation

@imatiach-msft
Copy link
Copy Markdown
Collaborator

@imatiach-msft imatiach-msft commented Feb 24, 2023

Seeing gated builds fail due to new errors:

./python/interpret_community/mimic/models/linear_model.py:45:[13](https://github.com/interpretml/interpret-community/actions/runs/4264305493/jobs/7422204144#step:6:14): B028 No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.
./python/interpret_community/widget/explanation_dashboard.py:55:9: B028 No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.
./tests/common_utils.py:160:9: B028 No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.

These warnings seem to have been added to the newer releases of flake8-bugbear extension package to flake8.

This PR fixes the error by explicitly setting the stacklevel argument on the warn method call. It seems it is recommended to set it to level 2 as it creates better warning messages by excluding the warn method itself from the printed stacktrace which can be confusing.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 24, 2023

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.83%. Comparing base (788c9e4) to head (4d52fb4).
⚠️ Report is 41 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #554   +/-   ##
=======================================
  Coverage   87.83%   87.83%           
=======================================
  Files          62       62           
  Lines        4094     4094           
=======================================
  Hits         3596     3596           
  Misses        498      498           
Flag Coverage Δ
unittests 87.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@imatiach-msft imatiach-msft merged commit 93232b5 into interpretml:main Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants