shutup
Advanced tools
+2
-1
| Metadata-Version: 2.1 | ||
| Name: shutup | ||
| Version: 0.1.3 | ||
| Version: 0.2.0 | ||
| Summary: Stop python warnings, no matter what! | ||
@@ -9,2 +9,3 @@ Author: Fred Israel | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: Programming Language :: Python :: 3.10 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
@@ -11,0 +12,0 @@ Classifier: Programming Language :: Python :: 3.6 |
+6
-2
| [tool.poetry] | ||
| name = "shutup" | ||
| version = "0.1.3" | ||
| version = "0.2.0" | ||
| description = "Stop python warnings, no matter what!" | ||
@@ -14,3 +14,7 @@ authors = ["Fred Israel <fredpublico@gmail.com>"] | ||
| [build-system] | ||
| requires = ["poetry-core>=1.0.0"] | ||
| # using feature not released yet on pypi | ||
| requires = ["poetry-core @ git+https://github.com/python-poetry/poetry-core.git@master"] | ||
| # requires = ["poetry-core>=1.0.0"] | ||
| build-backend = "poetry.core.masonry.api" | ||
+1
-1
@@ -12,3 +12,3 @@ # -*- coding: utf-8 -*- | ||
| 'name': 'shutup', | ||
| 'version': '0.1.3', | ||
| 'version': '0.2.0', | ||
| 'description': 'Stop python warnings, no matter what!', | ||
@@ -15,0 +15,0 @@ 'long_description': None, |
+40
-5
@@ -6,7 +6,42 @@ try: | ||
| import warnings as _warnings | ||
| _original_warn = None | ||
| def _warn(message:str, category:str='', stacklevel:int=1, source:str=''): # need hints to work with pytorch | ||
| pass # In the future, we can implement filters here. For now, just mute everything. | ||
| def please(): | ||
| import warnings | ||
| please._orig_warning = warnings.warn | ||
| def warn(message:str, category:str='', stacklevel:int=1, source:str=''): # need hints to work with pytorch | ||
| pass # In the future, we can implement filters here. For now, just mute everything. | ||
| warnings.warn = warn | ||
| global _original_warn | ||
| _original_warn = _warnings.warn | ||
| _warnings.warn = _warn | ||
| def jk(): | ||
| global _original_warn | ||
| if not _original_warn: return | ||
| _warnings.warn = _original_warn | ||
| _original_warn = None | ||
| def are_warnings_muted(): | ||
| return _original_warn != None | ||
| class _mute_warnings: | ||
| ''' Mute all warnings. Can also be used as a context manager.''' | ||
| def __call__(self): | ||
| please() | ||
| def __enter__(self): | ||
| self.muted = are_warnings_muted() | ||
| please() | ||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| if not self.muted: jk() | ||
| mute_warnings = _mute_warnings() | ||
| class unmute_warnings: | ||
| ''' Unmute warnings if previously muted. Otherwise, do nothing. Can also be used as a context manager. ''' | ||
| def __call__(self): | ||
| jk() | ||
| def __enter__(self): | ||
| self.muted = are_warnings_muted() | ||
| jk() | ||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| if self.muted: please() | ||
| unmute_warnings = unmute_warnings() |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
2901
63.99%60
93.55%