lint: fix some warnings

This commit is contained in:
Casper da Costa-Luis 2021-02-22 22:42:24 +00:00
parent b612be49cc
commit bbf40d242b
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
5 changed files with 11 additions and 9 deletions

View File

@ -22,7 +22,7 @@ class Comparison:
def run(self, cls):
pbar = cls(self.iterable)
t0 = self.time()
[0 for _ in pbar]
[0 for _ in pbar] # pylint: disable=pointless-statement
t1 = self.time()
return t1 - t0

View File

@ -7,3 +7,5 @@ except ImportError:
if args:
return args[0]
return kwargs.get('iterable', None)
__all__ = ['tqdm']

View File

@ -61,7 +61,7 @@ def test_main_import():
sys.argv = ['', '--desc', 'Test CLI import',
'--ascii', 'True', '--unit_scale', 'True']
try:
import tqdm.__main__ # NOQA
import tqdm.__main__ # NOQA, pylint: disable=unused-variable
finally:
sys.stdin, sys.argv = _SYS

View File

@ -1,7 +1,7 @@
from warnings import warn
from .std import TqdmDeprecationWarning
from .utils import ( # NOQA
from .utils import ( # NOQA, pylint: disable=unused-import
CUR_OS, IS_NIX, IS_WIN, RE_ANSI, Comparable, FormatReplace, SimpleTextIOWrapper,
_basestring, _environ_cols_wrapper, _is_ascii, _is_utf, _range, _screen_shape_linux,
_screen_shape_tput, _screen_shape_windows, _screen_shape_wrapper, _supports_unicode,

View File

@ -248,9 +248,9 @@ class tqdm_notebook(std_tqdm):
if not self.disable:
self.display()
def __iter__(self, *args, **kwargs):
def __iter__(self):
try:
for obj in super(tqdm_notebook, self).__iter__(*args, **kwargs):
for obj in super(tqdm_notebook, self).__iter__():
# return super(tqdm...) will not catch exception
yield obj
# NB: except ... [ as ...] breaks IPython async KeyboardInterrupt
@ -260,9 +260,9 @@ class tqdm_notebook(std_tqdm):
# NB: don't `finally: close()`
# since this could be a shared bar which the user will `reset()`
def update(self, *args, **kwargs):
def update(self, n=1):
try:
return super(tqdm_notebook, self).update(*args, **kwargs)
return super(tqdm_notebook, self).update(n=n)
# NB: except ... [ as ...] breaks IPython async KeyboardInterrupt
except: # NOQA
# cannot catch KeyboardInterrupt when using manual tqdm
@ -272,8 +272,8 @@ class tqdm_notebook(std_tqdm):
# NB: don't `finally: close()`
# since this could be a shared bar which the user will `reset()`
def close(self, *args, **kwargs):
super(tqdm_notebook, self).close(*args, **kwargs)
def close(self):
super(tqdm_notebook, self).close()
# Try to detect if there was an error or KeyboardInterrupt
# in manual mode: if n < total, things probably got wrong
if self.total and self.n < self.total: