Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/polvoazul/shutup
Stop python warnings, no matter what!
https://github.com/polvoazul/shutup
Last synced: 7 days ago
JSON representation
Stop python warnings, no matter what!
- Host: GitHub
- URL: https://github.com/polvoazul/shutup
- Owner: polvoazul
- License: wtfpl
- Created: 2021-06-29T20:04:07.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-10T20:46:32.000Z (over 2 years ago)
- Last Synced: 2024-08-02T17:34:07.880Z (3 months ago)
- Language: Python
- Size: 10.7 KB
- Stars: 149
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SHUTUP - Stop python warnings, no matter what!
Sometimes you just can't mute python warnings. Use this library to solve this.
## Installation
```bash
pip install shutup
```## Basic Use
At the beginning of your code (before you import other things), add this line:
```python
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:```python
shutup.jk()
```to re-enable warnings if you need them.
### Clean aliases
You can also use:```python
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:```python
import shutup
shutup.mute_warnings()
# Annoying codewith shutup.unmute_warnings:
# code that doesn't cry wolf
```Note that you shouldn't use `()` in a context manager:
```python
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! 🤦
> :warning: Note that muting and unmutting is **not a thread safe operation**.