SHUTUP - Stop python warnings, no matter what!
Sometimes you just can't mute python warnings. Use this library to solve this.
Installation
pip install shutup
Basic Use
At the beginning of your code (before you import other things), add this line:
import shutup; shutup.please()
That's it. Enjoy the silence :)
Contributions
If your warnings were not silenced, please open an issue. PRs, ideas and other contributions are also welcome.
Other features
Unmutting
You can use:
shutup.jk()
to re-enable warnings if you need them.
Clean aliases
You can also use:
shutup.mute_warnings()
shutup.unmute_warnings()
They are the same as the functions above, but they have cleaner (but arguably less funny) names.
Context Managers
Context managers are also supported:
import shutup
shutup.mute_warnings()
# Annoying code
with shutup.unmute_warnings:
# code that doesn't cry wolf
Note that you shouldn't use ()
in a context manager:
with shutup.mute_warnings: # correct
with shutup.mute_warnings(): # wrong
When context managers exit, they will reset warnings to muted/unmuted based on their state before entering.
Finally, this package needs its own warning! 🤦
⚠️ Note that muting and unmutting is not a thread safe operation.