Skip to content

Can the IPython directive use warnings for errors? #11547

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
TomAugspurger opened this issue Jan 7, 2019 · 8 comments · Fixed by #13030
Closed

Can the IPython directive use warnings for errors? #11547

TomAugspurger opened this issue Jan 7, 2019 · 8 comments · Fixed by #13030

Comments

@TomAugspurger
Copy link

Pandas would like to have a workflow where

  1. the documentation build always completes to the end, even if there are warnings
  2. the CI fails if there are any warnings.

For regular sphinx things, this works with a combination of -W error --keep-going, which fails the job at the end of the build if there were any warnings.

This doesn't work with exceptions in IPython blocks. Here's a small example

Welcome to test's documentation!
================================

.. ipython:: python

   2 + 'a'

The rest of the biuld

.. ipython:: python

   2 + 2

And the relevant IPytyhon conf setting is ipython_warning_is_error = False.

When I run

sphinx-build -W --keep-going "." _build/

The entire document is built, but the exit code is 0, when I'd like it to be 1.

I hope this is just because exceptions in IPython blocks are printed to stdout. On some basic testing, it looks like using sphinx.util.logging and logger.warning rather than sys.stdout.write will satisfy my needs.

Are the IPython devs open to changing from sys.stdout.write to logger.warning for this?

cc @tacaswell, and idea if this change would break matplotlib at all?

@Carreau
Copy link
Member

Carreau commented Jan 8, 2019

That seem to be reasonable to me. Feel free to send a pull request.

@LucianaMarques might also want to take a shot at it ?

@LucianaMarques
Copy link
Contributor

@Carreau yes, thank you! :)

@TomAugspurger I would like to contribute to make this work, can we discuss it? Thanks!

@TomAugspurger
Copy link
Author

TomAugspurger commented Jan 9, 2019 via email

@LucianaMarques
Copy link
Contributor

@TomAugspurger thank you for the explanation, I will take a loot at it and get back here.

@LucianaMarques
Copy link
Contributor

@Carreau could you assign this to me, please?

@Carreau
Copy link
Member

Carreau commented Feb 21, 2019

Could you assign this to me, please?

I don't think I can assign to people that do not have commit rights. Just leaving a comment saying you want to work on it is enough.

@tacaswell
Copy link
Contributor

Matplotlib also wants to fail CI if there are any errors in the docs.

@tacaswell
Copy link
Contributor

Which is to say I am 👍 on this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants