From 3454cc86b2980b4cd81df10aae52a6f0a4620ee3 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 6 Apr 2018 17:28:28 +0100 Subject: [PATCH] TqdmExperimentalWarning for GUI --- tqdm/__init__.py | 6 ++++-- tqdm/_tqdm.py | 8 ++++++-- tqdm/_tqdm_gui.py | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tqdm/__init__.py b/tqdm/__init__.py index 23c0f6ae..d6b251fe 100644 --- a/tqdm/__init__.py +++ b/tqdm/__init__.py @@ -6,13 +6,15 @@ from ._tqdm_pandas import tqdm_pandas from ._main import main from ._monitor import TMonitor, TqdmSynchronisationWarning from ._version import __version__ # NOQA -from ._tqdm import TqdmTypeError, TqdmKeyError, \ - TqdmWarning, TqdmDeprecationWarning, TqdmMonitorWarning +from ._tqdm import TqdmTypeError, TqdmKeyError, TqdmWarning, \ + TqdmDeprecationWarning, TqdmExperimentalWarning, \ + TqdmMonitorWarning __all__ = ['tqdm', 'tqdm_gui', 'trange', 'tgrange', 'tqdm_pandas', 'tqdm_notebook', 'tnrange', 'main', 'TMonitor', 'TqdmTypeError', 'TqdmKeyError', 'TqdmWarning', 'TqdmDeprecationWarning', + 'TqdmExperimentalWarning', 'TqdmMonitorWarning', 'TqdmSynchronisationWarning', '__version__'] diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 26a32d94..0eafbf0a 100755 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -27,8 +27,9 @@ from warnings import warn __author__ = {"github.com/": ["noamraph", "obiwanus", "kmike", "hadim", "casperdcl", "lrq3000"]} __all__ = ['tqdm', 'trange', - 'TqdmTypeError', 'TqdmKeyError', - 'TqdmWarning', 'TqdmDeprecationWarning', 'TqdmMonitorWarning'] + 'TqdmTypeError', 'TqdmKeyError', 'TqdmWarning', + 'TqdmExperimentalWarning', 'TqdmDeprecationWarning', + 'TqdmMonitorWarning'] class TqdmTypeError(TypeError): @@ -50,6 +51,9 @@ class TqdmWarning(Warning): else: super(TqdmWarning, self).__init__(msg, *a, **k) +class TqdmExperimentalWarning(TqdmWarning, FutureWarning): + """beta feature, unstable API and behaviour""" + pass class TqdmDeprecationWarning(TqdmWarning, DeprecationWarning): # not suppressed if raised diff --git a/tqdm/_tqdm_gui.py b/tqdm/_tqdm_gui.py index 65645dd5..13420ef7 100644 --- a/tqdm/_tqdm_gui.py +++ b/tqdm/_tqdm_gui.py @@ -15,7 +15,8 @@ from __future__ import division, absolute_import from time import time from ._utils import _range # to inherit from the tqdm class -from ._tqdm import tqdm +from ._tqdm import tqdm, TqdmExperimentalWarning +from warnings import warn __author__ = {"github.com/": ["casperdcl", "lrq3000"]} @@ -41,7 +42,7 @@ class tqdm_gui(tqdm): # pragma: no cover if self.disable or not kwargs['gui']: return - self.fp.write('Warning: GUI is experimental/alpha\n') + warn('GUI is experimental/alpha', TqdmExperimentalWarning) self.mpl = mpl self.plt = plt self.sp = None