-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Stop exiting early with --fail-on-warnings
; add --exception-on-warning
#12743
Conversation
My objective with #12727 is to be able to get into a pdb shell right where a warning is generated, because often that is necessary to debug issues. As far as I can tell, even with this PR I'd still need to make the |
I'll need a laptop for that review so only next week. I don't have a strong opinion on those ideas because I never use sphinx with those options. If I need to debug I put prints everywhere... (I just hack my own Sphinx or use the dev branch) Otherwise I transform warnings into errors most of the time and have simpler builds (no autosummary, custom autodoc with hacks). I'll need to think of the different flows and scenarios but I'd like to review it on my laptop. If you're in a hurry, I'd suggest asking @chrisjsewell as well since he has more insight on those options in general I think. |
Heya, but... it does feel quite the breaking change, maybe moreso given we have only just released I feel there is a number of different behaviours people may want here:
I think perhaps there is the case for two flags: |
Previously, warnings emitted during reading and writing were deferred, which made --pdb ineffective for debugging them. With this change, warnings are no longer deferred when --pdb and --debug-warnings are both specified. Co-authored-by: Jeremy Maitin-Shepard <jbms@google.com>
--fail-on-warnings
--fail-on-warnings
; add --debug-warnings
@jbms I've adapted your patch and merged it into this branch. My new proposal is that A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Chris that those changes are breaking changes and I don't think it should be added to 8.x but rather to 9.x.
Apart from what Chris said, there is a category of people that likely want to exit as soon as possible, but without necessarily using pdb
. Namely, they want to turn warnings into errors but don't want to debug them programatically. In other words, the current --fail-on-warning
behaviour should be kept but we could instead try to make the traceback nicer (though I don't know if it's possible).
Personally, I don't mind keeping the status quo for the current --fail-on-warning/--keep-going
while adding --debug-warnings
when running pdb. For me those are two different issues.
I disagree that this is a breaking change, as the important behaviour (exit codes) is maintained.
I'm not really convinced by this -- I think the current behaviour isn't optimal user experience, and we wouldn't design a system like that today. Contrast with a linter like Flake8, MyPy, or Ruff -- they work hard to show as many errors as possible. Please could you expand on the rationale for keeping the current 'exit early' behaviour? I think that with the new debug warnings option, this is backwards compatible. A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you expand on the rationale for keeping the current 'exit early' behaviour?
FTR, I'm not against this feature (I'm a +0.5). You said:
means that on minor errors that are easily fixed, the entire build must be restarted, perhaps multiple times to fix errors incrementally
Where I disagree is that people might like to do it that way. For instance, it may not necessarily be the case that fixing one warning in the list of warnings would not create more warnings. So fixing one warning at a time could fix multiple warnings, or create new ones, that would then require to be fixed again. Now, I agree that this might not be the best idea as a default (hence my +0.5) but I still think it'd be nice to be able to fix the warnings incrementally without using pdb (which people may not know how to use). If you're not convinced, I don't mind giving up on this since what I suggested could also be considered as a "dirty and non-recommended approach to fix issues".
I disagree that this is a breaking change, as the important behaviour (exit codes) is maintained.
You (half)-convinced me on that matter. What is actually breaking is that --keep-going
is now a no-op. I'd suggest adding a deprecation warning in case the option is used (just create an Action class that does nothing except emitting a warning so that we can remove that option later).
# Conflicts: # CHANGES.rst # tests/test_builders/test_build_warnings.py # tests/test_quickstart.py # tests/test_util/test_util_logging.py
I agree, but let's not deprecate for a while. See the comment in the docs for |
I'm going to merge this -- @jbms please could you confirm if anything further is needed for your goals? A |
|
I'm happy to change to A |
--fail-on-warnings
; add --debug-warnings
--fail-on-warnings
; add --exception-on-warning
I'm sure I could hunt one down, but really that is not the point; the point is that sphinx has the option now and, with this, it will no longer. Also sphinx is different to something like say ruff, in that it can be a lot slower; taking many minutes rather than milliseconds. I know of sphinx builds that can even take up to hours to build and so, especially on CI, sometimes people do not want to not waste time running the build to completion, just to see if the CI build fails. Take for example: https://github.com/numpy/numpy/blob/be296e2c032f7fbf30534fbe40af43c9f6b6f914/.circleci/config.yml#L77, |
This is persuasive, I suppose mypy & ruff are in the order of seconds, whereas Sphinx is in the order of minutes. With the update you suggested, we maintain the ability to "fail fast" with A |
FWIW having the ability to set |
This is sort-of an alternative to #12727 (cc @jbms), but also is something I've wanted to do for a while.
Currently, using
--fail-on-warnings
gives a fairly hard to understand traceback (as it is traced back from theWarningIsErrorFilter
rather than the warning itself) and means that on minor errors that are easily fixed, the entire build must be restarted, perhaps multiple times to fix errors incrementally.We have for some time reccommended
--keep-going
, which was added in Sphinx 1.8. This PR removes the "early exit" behaviour and instead exits with a non-zero status if errors were found. The--keep-going
option andsphinx.logging.skip_warningiserror()
context manager are retained, but become no-ops.As a result, there are quite a few simplifications we can make.
A