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

replace DeprecationWarning (et al?) by FutureWarning so that users see them #310

Closed
gdementen opened this issue Jun 9, 2017 · 5 comments

Comments

@gdementen
Copy link
Contributor

... but we want our users to see them.

There are several options to see them, none of which seems very appealing.

  • advise our users to systematically add this to all their modules:
import warnings
warnings.filterwarnings("default", category=DeprecationWarning, module="__main__")

... but this is tedious and they will not do it.

  • advise our users to run their interpreter with -W
    a bit hard to explain how to do that but less tedious. The problem is that they get lots of deprecation warnings from internal code (eg. ipython using deprecated zmq api), which makes it almost useless.
  • use FutureWarning instead of DeprecationWarning everywhere.
    in that case, we have what we want when users run their models but loose a nifty PyCharm feature which strikes through all functions which "raise" a DeprecationWarning.
  • try to come up with some insane code which does something like the first point automatically by inspecting the frame to see who imported larray.

PS: This is the case since 2.7 and the reasoning was that end-users (those using programs written in Python) should not see those kinds of warnings and that developers should run with -W anyway.

@gdementen gdementen added the bug label Jun 9, 2017
@alixdamman
Copy link
Collaborator

I already used FuturWarning for ipfp. Replacing DeprecationWarning by FuturWarning is my favorite option.

@gdementen
Copy link
Contributor Author

Yes, but in that case, you did not loose PyCharm's feature anyway.

@alixdamman
Copy link
Collaborator

which feature?

@gdementen
Copy link
Contributor Author

In user code, it strikes through functions which are deprecated

@gdementen
Copy link
Contributor Author

a few more options, for completeness:

  • emit both
  • detect if DeprecationWarnings are ignored, if so emit a FutureWarning (or both), otherwise emit only a FutureWarning
  • add warnings.simplefilter('default', DeprecationWarning) somewhere in larray code, but explicitly ignore all warnings we are aware of by wrapping them in:
with warnings.catch_warnings():
    warnings.simplefilter("ignore")

But I think simply using a FutureWarning is our best option anyway.

@gdementen gdementen changed the title DeprecationWarning (and a few others) are hidden by default replace DeprecationWarning (et al?) by FutureWarning so that users see them Aug 8, 2017
@gdementen gdementen modified the milestone: 0.25.2 Aug 28, 2017
@gdementen gdementen modified the milestones: 0.25.2, 0.25.1 Sep 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants