Skip to content
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

Prevent warning repeats #5506

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

stephenworsley
Copy link
Contributor

🚀 Pull Request

Attempts to address #5464, the result of investigations done for #5499.

This approach attempts to align the behaviour of warnings more closely with what ought to be the default behaviour of warnings. This currently comes at the expense of "hard coding" some of this behaviour to match what you would get when calling warnings.simplefilter("default"). When setting warnings.simplefilter("always") the expected behaviour would be for all warnings to be raised, however some will be caught, as per the behaviour of warnings.simplefilter("default"). Similarly, this does not go as far as to guarantee that warnings.simplefilter("once") will behave as expected, though it should not introduce any duplications that weren't already present.

The above problems could potentially be solved with some additional logic if I could figure out a way to determine which of these behaviours warnings expected at any given point in the code. Otherwise, it may be an acceptable payoff to hardcode this behaviour if it would reduce unwanted warnings in most cases.

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a47fd34) 89.71% compared to head (83859f7) 89.37%.
Report is 5 commits behind head on main.

❗ Current head 83859f7 differs from pull request most recent head 7e8871e. Consider uploading reports for the commit 7e8871e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5506      +/-   ##
==========================================
- Coverage   89.71%   89.37%   -0.34%     
==========================================
  Files          90       89       -1     
  Lines       22815    22456     -359     
  Branches     5438     5388      -50     
==========================================
- Hits        20468    20071     -397     
- Misses       1617     1639      +22     
- Partials      730      746      +16     

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

@trexfeathers
Copy link
Contributor

trexfeathers commented Sep 21, 2023

Before

image

After

image

(forgive the difference in test numbers - different PRs)

@trexfeathers
Copy link
Contributor

Thanks @ESadek-MO and @stephenworsley for exploring alternative solutions (#5536). I'm still unhappy that this PR effectively disables some of the actions in the Python warnings filter, but we've effectively been backed into that corner by forces outside our control.

Thankfully, we now have documentation about Iris warnings: filtering_warnings.rst. I would be worth:

  1. Adding a heading/admonitions to filtering_warnings.rst to clearly document Iris' deviation from standard Python behaviour.
  2. Reviewing the existing text of filtering_warnings.rst to check it is not misleading in light of the changes in this PR.

Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous comment: #5506 (comment)

lib/iris/exceptions.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: paused
Status: No status
Development

Successfully merging this pull request may close these issues.

Experiment with community workarounds to duplicated warnings
4 participants