diff --git a/.meta/mksnap.py b/.meta/mksnap.py index e06c17613..1b70416f5 100644 --- a/.meta/mksnap.py +++ b/.meta/mksnap.py @@ -5,7 +5,7 @@ import sys from io import open as io_open from os import path -from subprocess import check_output +from subprocess import check_output # nosec sys.path.insert(1, path.dirname(path.dirname(__file__))) import tqdm # NOQA @@ -65,7 +65,7 @@ command: bin/tqdm completer: completion.sh """.format(version=tqdm.__version__, commit=check_output([ - 'git', 'describe', '--always']).decode('U8').strip()) + 'git', 'describe', '--always']).decode('U8').strip()) # nosec fname = path.join(path.dirname(src_dir), 'snapcraft.yaml') if __name__ == "__main__": diff --git a/examples/7zx.py b/examples/7zx.py index 892dcf764..c5bc28b7e 100644 --- a/examples/7zx.py +++ b/examples/7zx.py @@ -25,7 +25,7 @@ import os import pty import re -import subprocess +import subprocess # nosec from argopt import argopt @@ -51,7 +51,7 @@ def main(): # Get compressed sizes zips = {} for fn in args.zipfiles: - info = subprocess.check_output(["7z", "l", fn]).strip() + info = subprocess.check_output(["7z", "l", fn]).strip() # nosec finfo = RE_SCN.findall(info) # size|compressed|name # builtin test: last line should be total sizes @@ -81,7 +81,7 @@ def main(): cmd7zx + [fn], bufsize=1, stdout=md, # subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT) # nosec os.close(sd) with io.open(md, mode="rU", buffering=1) as m: with tqdm(total=sum(fcomp.values()), disable=len(zips) < 2, diff --git a/examples/parallel_bars.py b/examples/parallel_bars.py index 2e8a9c3b8..498fd61df 100644 --- a/examples/parallel_bars.py +++ b/examples/parallel_bars.py @@ -16,7 +16,7 @@ def progresser(n, auto_position=True, write_safe=False, blocking=True, progress=False): - interval = random() * 0.002 / (NUM_SUBITERS - n + 2) + interval = random() * 0.002 / (NUM_SUBITERS - n + 2) # nosec total = 5000 text = "#{0}, est. {1:<04.2}s".format(n, interval * total) for _ in trange(total, desc=text, disable=not progress, diff --git a/examples/tqdm_wget.py b/examples/tqdm_wget.py index 3cd5e7404..8663e5a39 100644 --- a/examples/tqdm_wget.py +++ b/examples/tqdm_wget.py @@ -100,12 +100,12 @@ def update_to(self, b=1, bsize=1, tsize=None): # reporthook=my_hook(t), data=None) with TqdmUpTo(unit='B', unit_scale=True, unit_divisor=1024, miniters=1, desc=eg_file) as t: # all optional kwargs - urllib.urlretrieve(eg_link, filename=eg_out, reporthook=t.update_to, - data=None) + urllib.urlretrieve( # nosec + eg_link, filename=eg_out, reporthook=t.update_to, data=None) t.total = t.n # Even simpler progress by wrapping the output file's `write()` -response = urllib.urlopen(eg_link) +response = urllib.urlopen(eg_link) # nosec with tqdm.wrapattr(open(eg_out, "wb"), "write", miniters=1, desc=eg_file, total=getattr(response, 'length', None)) as fout: diff --git a/tests/tests_main.py b/tests/tests_main.py index 44d0b7878..aa477e5b5 100644 --- a/tests/tests_main.py +++ b/tests/tests_main.py @@ -1,6 +1,6 @@ """Test CLI usage.""" import logging -import subprocess +import subprocess # nosec import sys from functools import wraps from os import linesep @@ -34,11 +34,11 @@ def norm(bytestr): @mark.slow def test_pipes(): """Test command line pipes""" - ls_out = subprocess.check_output(['ls']) - ls = subprocess.Popen(['ls'], stdout=subprocess.PIPE) + ls_out = subprocess.check_output(['ls']) # nosec + ls = subprocess.Popen(['ls'], stdout=subprocess.PIPE) # nosec res = subprocess.Popen( [sys.executable, '-c', 'from tqdm.cli import main; main()'], - stdin=ls.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdin=ls.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # nosec out, err = res.communicate() assert ls.poll() == 0 diff --git a/tqdm/auto.py b/tqdm/auto.py index 370c180d6..28bc722da 100644 --- a/tqdm/auto.py +++ b/tqdm/auto.py @@ -30,7 +30,7 @@ from .std import tqdm as std_tqdm if notebook_tqdm != std_tqdm: - class tqdm(notebook_tqdm, asyncio_tqdm): + class tqdm(notebook_tqdm, asyncio_tqdm): # pylint: disable=inconsistent-mro pass else: tqdm = asyncio_tqdm diff --git a/tqdm/cli.py b/tqdm/cli.py index 7b7338458..b5a16142b 100644 --- a/tqdm/cli.py +++ b/tqdm/cli.py @@ -263,7 +263,7 @@ def cp(src, dst): stdout_write = stdout.write fp_write = getattr(fp, 'buffer', fp).write - class stdout(object): + class stdout(object): # pylint: disable=function-redefined @staticmethod def write(x): with tqdm.external_write_mode(file=fp): diff --git a/tqdm/utils.py b/tqdm/utils.py index 96c710f86..aae87e454 100644 --- a/tqdm/utils.py +++ b/tqdm/utils.py @@ -3,7 +3,6 @@ """ import os import re -import subprocess import sys from functools import wraps from warnings import warn @@ -254,7 +253,7 @@ def _screen_shape_windows(fp): # pragma: no cover (_bufx, _bufy, _curx, _cury, _wattr, left, top, right, bottom, _maxx, _maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw) return right - left, bottom - top # +1 - except Exception: + except Exception: # nosec pass return None, None @@ -263,9 +262,10 @@ def _screen_shape_tput(*_): # pragma: no cover """cygwin xterm (windows)""" try: import shlex - return [int(subprocess.check_call(shlex.split('tput ' + i))) - 1 + from subprocess import check_call # nosec + return [int(check_call(shlex.split('tput ' + i))) - 1 for i in ('cols', 'lines')] - except Exception: + except Exception: # nosec pass return None, None