]> arthur.barton.de Git - bup.git/commitdiff
test: add pylint and test imports
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 27 Aug 2021 20:23:37 +0000 (22:23 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 11 Sep 2021 17:22:28 +0000 (12:22 -0500)
Add pylint and test for unnecessary imports as a first step, which
requires cleaning them all up.

[rlb@defaultvalue.org: add and use ./pylint]

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
61 files changed:
.pylintrc [new file with mode: 0644]
GNUmakefile
lib/bup/bloom.py
lib/bup/client.py
lib/bup/cmd/bloom.py
lib/bup/cmd/cat_file.py
lib/bup/cmd/daemon.py
lib/bup/cmd/damage.py
lib/bup/cmd/fsck.py
lib/bup/cmd/ftp.py
lib/bup/cmd/fuse.py
lib/bup/cmd/gc.py
lib/bup/cmd/get.py
lib/bup/cmd/import_duplicity.py
lib/bup/cmd/index.py
lib/bup/cmd/init.py
lib/bup/cmd/list_idx.py
lib/bup/cmd/ls.py
lib/bup/cmd/memtest.py
lib/bup/cmd/meta.py
lib/bup/cmd/midx.py
lib/bup/cmd/mux.py
lib/bup/cmd/on__server.py
lib/bup/cmd/prune_older.py
lib/bup/cmd/restore.py
lib/bup/cmd/rm.py
lib/bup/cmd/server.py
lib/bup/cmd/split.py
lib/bup/cmd/tag.py
lib/bup/cmd/tick.py
lib/bup/cmd/version.py
lib/bup/cmd/web.py
lib/bup/cmd/xstat.py
lib/bup/compat.py
lib/bup/gc.py
lib/bup/git.py
lib/bup/hashsplit.py
lib/bup/helpers.py
lib/bup/index.py
lib/bup/ls.py
lib/bup/main.py
lib/bup/metadata.py
lib/bup/midx.py
lib/bup/pwdgrp.py
lib/bup/rm.py
lib/bup/ssh.py
lib/bup/tree.py
lib/bup/version.py
lib/bup/vfs.py
lib/bup/vint.py
pylint [new file with mode: 0755]
pytest
test/int/test_bloom.py
test/int/test_client.py
test/int/test_git.py
test/int/test_helpers.py
test/int/test_index.py
test/int/test_metadata.py
test/int/test_resolve.py
test/int/test_vfs.py
test/int/test_xstat.py

diff --git a/.pylintrc b/.pylintrc
new file mode 100644 (file)
index 0000000..74e7c1f
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,5 @@
+# -*-conf-*-
+
+[MESSAGES CONTROL]
+disable=all
+enable=unused-import,unused-wildcard-import
index 228b979467c6bfbf5ff51b4fb046c08de566092e..f648dfb65fd7f997d561027f61d7fdeb167528c0 100644 (file)
@@ -206,7 +206,10 @@ get_parallel_n = $(patsubst -j%,%,$(parallel_opt))
 maybe_specific_n = $(if $(filter -j%,$(parallel_opt)),-n$(get_parallel_n))
 xdist_opt = $(if $(filter -j,$(parallel_opt)),-nauto,$(maybe_specific_n))
 
-test: all test/tmp dev/python
+lint: dev/bup-python
+       ./pylint
+
+test: all test/tmp dev/python lint
         if test yes = "$$(dev/python -c 'import xdist; print("yes")' 2>/dev/null)"; then \
           (set -x; ./pytest $(xdist_opt);) \
         else \
index 18ed4608f3fd12046dd7a52d3dd9f0c95074fee5..f8ae3dd005927bcea2d6107a5d90b55b43f3d88f 100644 (file)
@@ -81,7 +81,7 @@ Brandon Low <lostlogic@lostlogicx.com> 2011-02-04
 """
 
 from __future__ import absolute_import
-import sys, os, math, mmap, struct
+import os, math, struct
 
 from bup import _helpers
 from bup.helpers import (debug1, debug2, log, mmap_read, mmap_readwrite,
index b37b71d2fff4d4df48a0631e243f96ab729c3c7d..9372d609c4464196cad6777a70a3d2b162b551d0 100644 (file)
@@ -3,7 +3,7 @@ from __future__ import print_function
 
 from __future__ import absolute_import
 from binascii import hexlify, unhexlify
-import errno, os, re, struct, sys, time, zlib
+import errno, os, re, struct, time, zlib
 import socket
 
 from bup import git, ssh, vfs
@@ -12,7 +12,7 @@ from bup.helpers import (Conn, atomically_replaced_file, chunkyreader, debug1,
                          debug2, linereader, lines_until_sentinel,
                          mkdirp, progress, qprogress, DemuxConn)
 from bup.io import path_msg
-from bup.vint import read_bvec, read_vuint, write_bvec
+from bup.vint import write_bvec
 
 
 bwlimit = None
index 996bea2ba15cbd507081b998407ebb850cb7c79b..27d26b148ec3b5232d4689f13c7c454cff539df8 100755 (executable)
@@ -3,9 +3,9 @@ from __future__ import absolute_import
 
 import os, glob, sys
 
-from bup import compat, options, git, bloom
+from bup import options, git, bloom
 from bup.compat import argv_bytes, hexstr
-from bup.helpers import (add_error, debug1, handle_ctrl_c, log, progress, qprogress,
+from bup.helpers import (add_error, debug1, log, progress, qprogress,
                          saved_errors)
 from bup.io import path_msg
 
index e45d1ea595b517af048cbe81f6a989f2c490219e..302d8e3d8200627bd49c0d613ed717caeb3727fb 100755 (executable)
@@ -5,7 +5,7 @@ import re, stat, sys
 
 from bup import options, git, vfs
 from bup.compat import argv_bytes
-from bup.helpers import chunkyreader, handle_ctrl_c, log, saved_errors
+from bup.helpers import chunkyreader, log, saved_errors
 from bup.io import byte_stream
 from bup.repo import LocalRepo
 
index d82e1e013489688ad3e6f384934e2f7791efd719..dca17b40866bcdabc6a8499a338025f7af139dc1 100755 (executable)
@@ -1,9 +1,9 @@
 
 from __future__ import absolute_import
-import fcntl, getopt, os, socket, subprocess, sys
+import fcntl, getopt, os, socket, subprocess, sys, select
 
 from bup import options, path
-from bup.helpers import *
+from bup.helpers import log, debug1
 
 
 optspec = """
index d3a177826271c82fa46bf2f80c0ff949fd29c9ba..1bd2aa191addcafabdb8b7390f698f6680536b9b 100755 (executable)
@@ -1,6 +1,6 @@
 
 from __future__ import absolute_import
-import os, random, sys
+import os, random
 
 from bup import options
 from bup.compat import argv_bytes, bytes_from_uint, range
index c195f77ea40680d25bf8e9666a32ae317c91002a..0725f539b6bfce7efddb9bebfe49464f92db202c 100755 (executable)
@@ -1,7 +1,7 @@
 
 from __future__ import absolute_import, print_function
 from shutil import rmtree
-from subprocess import PIPE, Popen
+from subprocess import PIPE
 from tempfile import mkdtemp
 from binascii import hexlify
 import glob, os, subprocess, sys
index 4982384c3c65f8178fd3bf038ec835e712faf323..8b7fe9d8d137e7ed1fdb5323d14eb0f20e4468b5 100755 (executable)
@@ -8,8 +8,8 @@ from __future__ import absolute_import, print_function
 import os, fnmatch, stat, sys
 
 from bup import _helpers, options, git, shquote, ls, vfs
-from bup.compat import argv_bytes, fsdecode
-from bup.helpers import chunkyreader, handle_ctrl_c, log
+from bup.compat import argv_bytes
+from bup.helpers import chunkyreader, log
 from bup.io import byte_stream, path_msg
 from bup.repo import LocalRepo
 
index 96bf6179ebe4800b05a8558d69011ca8b8a8386d..6307119704882ffed3905759c0b5a28836a75d59 100755 (executable)
@@ -27,7 +27,7 @@ if sys.version_info[0] > 2:
         sys.exit(2)
 
 from bup import options, git, vfs, xstat
-from bup.compat import argv_bytes, fsdecode, py_maj
+from bup.compat import argv_bytes, fsdecode
 from bup.helpers import log
 from bup.repo import LocalRepo
 
index e1b995a3885afc56da9a1f46c5b533e5d15e49cd..a3733faa5a756cee367827054f7caa7fbfbcaf36 100755 (executable)
@@ -3,7 +3,7 @@ from __future__ import absolute_import
 
 from bup import git, options
 from bup.gc import bup_gc
-from bup.helpers import die_if_errors, handle_ctrl_c, log
+from bup.helpers import die_if_errors
 
 
 optspec = """
index 8844544c0f7b0ae34a0fd4cbdb23fe39bb8a09ee..6c9b8ed249d0f3f2e701d7f19233d312a3a9e91d 100755 (executable)
@@ -2,22 +2,20 @@
 from __future__ import absolute_import, print_function
 from binascii import hexlify, unhexlify
 from collections import namedtuple
-from functools import partial
 from stat import S_ISDIR
 import os, sys, textwrap, time
 
-from bup import compat, git, client, helpers, vfs
+from bup import compat, git, client, vfs
 from bup.compat import (
     argv_bytes,
     bytes_from_byte,
     environ,
     hexstr,
     items,
-    wrap_main
 )
 from bup.git import get_cat_data, parse_commit, walk_object
-from bup.helpers import add_error, debug1, handle_ctrl_c, log, saved_errors
-from bup.helpers import hostname, shstr, tty_width
+from bup.helpers import add_error, debug1, log, saved_errors
+from bup.helpers import hostname, tty_width
 from bup.io import path_msg
 from bup.pwdgrp import userfullname, username
 from bup.repo import LocalRepo, RemoteRepo
index b2b011af54166652faaadd082e92d548a79e1d21..78ed1ee2fa8105b9f311ec641cedc9d1f09bf168 100755 (executable)
@@ -1,19 +1,15 @@
 
 from __future__ import absolute_import
 from calendar import timegm
-from pipes import quote
 from subprocess import check_call
-from time import strftime, strptime
+from time import strptime
 import os, sys, tempfile
 
 from bup import git, helpers, options
-from bup.compat import argv_bytes, str_type
-from bup.helpers import (handle_ctrl_c,
-                         log,
-                         readpipe,
+from bup.compat import argv_bytes
+from bup.helpers import (log,
                          shstr,
-                         saved_errors,
-                         unlink)
+                         saved_errors)
 import bup.path
 
 
index 86335857d67e9f04f02c1a83b56b3c6a878d91d8..35d393ad9b5db509621eb5a6033e1e022eed6fae 100755 (executable)
@@ -3,10 +3,10 @@ from __future__ import absolute_import, print_function
 from binascii import hexlify
 import errno, os, stat, sys, time
 
-from bup import compat, metadata, options, git, index, drecurse, hlinkdb
+from bup import metadata, options, git, index, hlinkdb
 from bup.compat import argv_bytes
 from bup.drecurse import recursive_dirlist
-from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE
+from bup.hashsplit import GIT_MODE_FILE
 from bup.helpers import (add_error, handle_ctrl_c, log, parse_excludes, parse_rx_excludes,
                          progress, qprogress, saved_errors)
 from bup.io import byte_stream, path_msg
index c354584ac6fb4bf45fbc7317b726f59e76c5d111..4be83a28351cf1a32969ff219320820ee8a5f884 100755 (executable)
@@ -3,7 +3,7 @@ from __future__ import absolute_import
 import sys
 
 from bup import git, options, client
-from bup.helpers import log, saved_errors
+from bup.helpers import log
 from bup.compat import argv_bytes
 
 
index 8bf940ef88a3d02f8bc4ec185dd4bb5b8137de92..15e8b4c836ca3970dc1f9449eacb063607b82ba7 100755 (executable)
@@ -1,7 +1,7 @@
 
 from __future__ import absolute_import, print_function
 from binascii import hexlify, unhexlify
-import os, sys
+import sys
 
 from bup import git, options
 from bup.compat import argv_bytes
index a7fc6dbeb243ff9cdeb016bd2d14d860b295f88a..29323ccf9bef98476ba17031ed45d3645244f91e 100755 (executable)
@@ -1,8 +1,8 @@
 
 from __future__ import absolute_import, print_function
-import os.path, sys
+import sys
 
-from bup import compat, git, ls
+from bup import git, ls
 from bup.io import byte_stream
 
 def main(argv):
index f62c64f11dbf44105c5883e34db3fa198680ede0..831ec54b4e9c28fae6c3e14a2f0de903ec116d00 100755 (executable)
@@ -4,7 +4,6 @@ import re, resource, sys, time
 
 from bup import git, bloom, midx, options, _helpers
 from bup.compat import range
-from bup.helpers import handle_ctrl_c
 from bup.io import byte_stream
 
 
index eab9101457507947dadcede871eb14ebd9cc3489..b0d477d8d33cd84ac8791c0f7cdf50724942cc23 100755 (executable)
@@ -8,11 +8,11 @@
 from __future__ import absolute_import
 import sys
 
-from bup import compat, metadata
+from bup import metadata
 from bup import options
 from bup.compat import argv_bytes
 from bup.io import byte_stream
-from bup.helpers import handle_ctrl_c, log, saved_errors
+from bup.helpers import log, saved_errors
 
 
 def open_input(name):
index e80afa1a171388f04bae8a02f8db0b4939503c8f..0d42958350a9950adadd83bb047de742042dea60 100755 (executable)
@@ -1,12 +1,12 @@
 
 from __future__ import absolute_import, print_function
 from binascii import hexlify
-import glob, os, math, resource, struct, sys, tempfile
+import glob, os, math, resource, struct, sys
 
 from bup import options, git, midx, _helpers, xstat
 from bup.compat import argv_bytes, hexstr, range
 from bup.helpers import (Sha1, add_error, atomically_replaced_file, debug1, fdatasync,
-                         handle_ctrl_c, log, mmap_readwrite, qprogress,
+                         log, mmap_readwrite, qprogress,
                          saved_errors, unlink)
 from bup.io import byte_stream, path_msg
 
index 606f027b6e28033d2428c497182aa5dd961ac79a..a804f72e8e85ffa9371fa91cae32aaf847de3668 100755 (executable)
@@ -1,6 +1,6 @@
 
 from __future__ import absolute_import
-import os, struct, subprocess, sys
+import os, subprocess, sys
 
 from bup import options
 from bup.helpers import debug1, debug2, mux
index c04b3b0c68207f0ffa16277c2ba2ef33fc73a269..13e2f84723fa457f763faa973de9e504211f40d6 100755 (executable)
@@ -3,7 +3,7 @@ from __future__ import absolute_import
 import os, struct, sys
 
 from bup import options, helpers, path
-from bup.compat import environ, py_maj
+from bup.compat import environ
 from bup.io import byte_stream
 
 optspec = """
index b3df6e9fb0979bc205133e8007e2558639d34c4c..e0f8545f5eaad8e4b9b0a30e0d3169637fde09d5 100755 (executable)
@@ -3,7 +3,6 @@ from __future__ import absolute_import, print_function
 from binascii import hexlify, unhexlify
 from collections import defaultdict
 from itertools import groupby
-from sys import stderr
 from time import localtime, strftime, time
 import sys
 
index 07643554d880c8a3ac6f654cfe577de18beac1ce..825493ffa6d09be40bd3559760d0447d836fe4d6 100755 (executable)
@@ -3,12 +3,12 @@ from __future__ import absolute_import
 from stat import S_ISDIR
 import copy, errno, os, re, stat, sys
 
-from bup import options, git, metadata, vfs
+from bup import options, git, vfs
 from bup._helpers import write_sparsely
-from bup.compat import argv_bytes, fsencode, wrap_main
-from bup.helpers import (add_error, chunkyreader, die_if_errors, handle_ctrl_c,
-                         log, mkdirp, parse_rx_excludes, progress, qprogress,
-                         saved_errors, should_rx_exclude_path, unlink)
+from bup.compat import argv_bytes, fsencode
+from bup.helpers import (add_error, chunkyreader, die_if_errors,
+                         mkdirp, parse_rx_excludes, progress, qprogress,
+                         should_rx_exclude_path)
 from bup.io import byte_stream
 from bup.repo import LocalRepo, RemoteRepo
 
index 75d35a2af9f2b3c6474f9d5ccdbd33cbeae140fb..2867657f87fa6a41b74cf57bf0a76bdd683c523b 100755 (executable)
@@ -4,7 +4,7 @@ from __future__ import absolute_import
 from bup.compat import argv_bytes
 from bup.git import check_repo_or_die
 from bup.options import Options
-from bup.helpers import die_if_errors, handle_ctrl_c, log
+from bup.helpers import die_if_errors
 from bup.repo import LocalRepo
 from bup.rm import bup_rm
 
index 3ff8a19164a7207c4c88fbf6f33b6692738fba10..7cb5a2a10107b797337ca5ee6f9ccdc1c39c4b11 100755 (executable)
@@ -5,7 +5,6 @@ import os, struct, subprocess, sys
 
 from bup import options, git, vfs, vint
 from bup.compat import environ, hexstr
-from bup.git import MissingObject
 from bup.helpers import (Conn, debug1, debug2, linereader, lines_until_sentinel,
                          log)
 from bup.io import byte_stream, path_msg
index 87ad88752ab854603578d1d4495a0a14164205e2..11392e208aed26d5981df22becbe3c5f6b7673f7 100755 (executable)
@@ -5,7 +5,7 @@ import sys, time
 
 from bup import compat, hashsplit, git, options, client
 from bup.compat import argv_bytes, environ
-from bup.helpers import (add_error, handle_ctrl_c, hostname, log, parse_num,
+from bup.helpers import (add_error, hostname, log, parse_num,
                          qprogress, reprogress, saved_errors,
                          valid_save_name,
                          parse_date_or_fatal)
index aaff755018fdac14753f519270232b8b09a5de97..0f5475d5050d883e24a4451e2a02f1baa72ef488 100755 (executable)
@@ -1,11 +1,11 @@
 
 from __future__ import absolute_import
 from binascii import hexlify
-import os, sys
+import sys
 
 from bup import git, options
 from bup.compat import argv_bytes
-from bup.helpers import debug1, handle_ctrl_c, log
+from bup.helpers import debug1, log
 from bup.io import byte_stream, path_msg
 
 
index e2dfa3956c1b4cc5635200c06f32ed9847de5e1a..82de69ba4b23cf9ef426469a924113eade78f3ca 100755 (executable)
@@ -1,6 +1,6 @@
 
 from __future__ import absolute_import
-import os, sys, time
+import time
 
 from bup import options
 
index 853fe4fefc800506c113407dfee539f005d35691..106846131497544b7c3800d60668585b1ce79582 100755 (executable)
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, print_function
 import re, sys
 
-from bup import compat, options, version
+from bup import options, version
 from bup.io import byte_stream
 
 version_rx = re.compile(r'^[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9]+-g[0-9abcdef]+)?$')
index cae0d46ebe0b85ed08c4cf513458332f83faa6a8..ccac6faaecc8da780bcfdb60ab0d1d7d4c6c5ef6 100755 (executable)
@@ -1,14 +1,13 @@
 
 from __future__ import absolute_import, print_function
 from collections import namedtuple
-import mimetypes, os, posixpath, signal, stat, sys, time, urllib, webbrowser
+import mimetypes, os, posixpath, signal, stat, sys, time, webbrowser
 from binascii import hexlify
 
 
 from bup import options, git, vfs
-from bup.helpers import (chunkyreader, debug1, format_filesize, handle_ctrl_c,
+from bup.helpers import (chunkyreader, debug1, format_filesize,
                          log, saved_errors)
-from bup.metadata import Metadata
 from bup.path import resource_path
 from bup.repo import LocalRepo
 from bup.io import path_msg
index 0cf8bdc6176a887d51c63c219d155b917a4153f5..246af24f3a9b3031a5878f55cb3c5ba1de3fbc58 100755 (executable)
@@ -5,11 +5,11 @@
 
 from __future__ import absolute_import, print_function
 
-import errno, stat, sys
+import errno, sys
 
-from bup import compat, metadata, options, xstat
+from bup import metadata, options
 from bup.compat import argv_bytes
-from bup.helpers import add_error, handle_ctrl_c, parse_timestamp, saved_errors, \
+from bup.helpers import add_error, parse_timestamp, saved_errors, \
     add_error, log
 from bup.io import byte_stream
 
index a06ffe8ee581d9cab13e1764740241768d2d2210..fb45ead5d6e100fdcc0d37910d42e69f6e72793c 100644 (file)
@@ -1,6 +1,5 @@
 
 from __future__ import absolute_import, print_function
-from array import array
 from binascii import hexlify
 from traceback import print_exception
 import os, sys
@@ -13,6 +12,7 @@ py3 = py_maj >= 3
 
 if py3:
 
+    # pylint: disable=unused-import
     from os import environb as environ
     from os import fsdecode, fsencode
     from shlex import quote
@@ -88,8 +88,10 @@ else:  # Python 2
         return x
 
     from pipes import quote
+    # pylint: disable=unused-import
     from os import environ, getcwd
 
+    # pylint: disable=unused-import
     from bup.py2raise import reraise
 
     input = raw_input
index 4009e8154ef71f87f8b1233ffae46a3f55518888..b757034c827f06a3a1a89a7701c8381ca55aedcc 100644 (file)
@@ -5,7 +5,7 @@ from os.path import basename
 import glob, os, subprocess, sys, tempfile
 
 from bup import bloom, git, midx
-from bup.compat import hexstr, pending_raise, range
+from bup.compat import hexstr, pending_raise
 from bup.git import MissingObject, walk_object
 from bup.helpers import Nonlocal, log, progress, qprogress
 from bup.io import path_msg
index ec84dd7b0e071aca2af8888f80a08416d3fa9d38..cccc44ef97655f79a8755d65990c55edae1c1e02 100644 (file)
@@ -4,14 +4,13 @@ interact with the Git data structures.
 """
 
 from __future__ import absolute_import, print_function
-import errno, os, sys, zlib, time, subprocess, struct, stat, re, tempfile, glob
+import os, sys, zlib, subprocess, struct, stat, re, tempfile, glob
 from array import array
 from binascii import hexlify, unhexlify
 from collections import namedtuple
 from itertools import islice
-from numbers import Integral
 
-from bup import _helpers, compat, hashsplit, path, midx, bloom, xstat
+from bup import _helpers, hashsplit, path, midx, bloom, xstat
 from bup.compat import (buffer,
                         byte_int, bytes_from_byte, bytes_from_uint,
                         environ,
@@ -22,15 +21,13 @@ from bup.io import path_msg
 from bup.helpers import (Sha1, add_error, chunkyreader, debug1, debug2,
                          exo,
                          fdatasync,
-                         hostname, localtime, log,
+                         log,
                          merge_dict,
                          merge_iter,
                          mmap_read, mmap_readwrite,
-                         parse_num,
                          progress, qprogress, stat_if_exists,
                          unlink,
                          utc_offset_str)
-from bup.pwdgrp import username, userfullname
 
 
 verbose = 0
index 94d93ed36746ebb31e9dfa4bdf11ca1a205af80c..16ccbb15f8152935567707defe84c9d3b26013aa 100644 (file)
@@ -2,9 +2,9 @@
 from __future__ import absolute_import
 import io, math, os
 
-from bup import _helpers, compat, helpers
+from bup import _helpers, helpers
 from bup._helpers import cat_bytes
-from bup.compat import buffer, py_maj
+from bup.compat import buffer
 from bup.helpers import sc_page_size
 
 
index a0679452a6e34c7514080db804d621fb99206d57..b0cff727d0b3e9453a6bf2e473a7356229fc06d6 100644 (file)
@@ -7,8 +7,8 @@ from ctypes import sizeof, c_void_p
 from math import floor
 from os import environ
 from subprocess import PIPE, Popen
-import sys, os, pwd, subprocess, errno, socket, select, mmap, stat, re, struct
-import hashlib, heapq, math, operator, time, grp, tempfile
+import sys, os, subprocess, errno, select, mmap, stat, re, struct
+import hashlib, heapq, math, operator, time, tempfile
 
 from bup import _helpers
 from bup import compat
index 6b773ceac74d86e7f5bd455fa2a3e41604fce9a4..a2abfa7a266bd84338b8b7365af61cd05a9e07f0 100644 (file)
@@ -2,7 +2,7 @@
 from __future__ import absolute_import, print_function
 import errno, os, stat, struct, tempfile
 
-from bup import compat, metadata, xstat
+from bup import metadata, xstat
 from bup._helpers import UINT_MAX, bytescmp
 from bup.compat import range
 from bup.helpers import (add_error, log, merge_iter, mmap_readwrite,
index 4bd673022cc8379cd07e2049aaafcfc51ccf98cf..755c9981878385a2222b2223c8d53d9006ff2a83 100644 (file)
@@ -3,16 +3,16 @@
 from __future__ import absolute_import
 from binascii import hexlify
 from itertools import chain
-from stat import S_ISDIR, S_ISLNK
-import copy, locale, os.path, stat, sys
+from stat import S_ISDIR
+import os.path
 import posixpath
 
-from bup import metadata, options, vfs, xstat
+from bup import metadata, vfs, xstat
 from bup.compat import argv_bytes
 from bup.io import path_msg
 from bup.options import Options
 from bup.repo import LocalRepo, RemoteRepo
-from bup.helpers import columnate, istty1, last, log
+from bup.helpers import columnate, istty1, log
 
 def item_hash(item, tree_for_commit):
     """If the item is a Commit, return its commit oid, otherwise return
index e24bee9b9f45194624aeca345109bb0eaf6fb9c8..0234a1b68ede1f57ff1ed2cc71b924b663cf1b18 100755 (executable)
@@ -14,23 +14,21 @@ from importlib import import_module
 from pkgutil import iter_modules
 from subprocess import PIPE
 from threading import Thread
-import errno, re, select, signal, subprocess
+import re, select, signal, subprocess
 
 from bup import compat, path, helpers
 from bup.compat import (
     ModuleNotFoundError,
     add_ex_ctx,
     add_ex_tb,
-    argv_bytes,
     environ,
     fsdecode,
     int_types,
     wrap_main
 )
-from bup.compat import add_ex_tb, add_ex_ctx, argv_bytes, wrap_main
+from bup.compat import add_ex_tb, add_ex_ctx, wrap_main
 from bup.helpers import (
     columnate,
-    debug1,
     handle_ctrl_c,
     log,
     merge_dict,
index b68c9851f3c9e82bf79e3f640fc69154fe89eaf7..a20b67b492425a3462c16a49b5b0c95402c57f0a 100644 (file)
@@ -6,15 +6,13 @@
 # Public License as described in the bup LICENSE file.
 
 from __future__ import absolute_import, print_function
-from binascii import hexlify
 from copy import deepcopy
 from errno import EACCES, EINVAL, ENOTTY, ENOSYS, EOPNOTSUPP
 from io import BytesIO
 from time import gmtime, strftime
-import errno, os, sys, stat, time, pwd, grp, socket, struct
+import errno, os, sys, stat, time, socket, struct
 
-from bup import compat, vint, xstat
-from bup.compat import py_maj
+from bup import vint, xstat
 from bup.drecurse import recursive_dirlist
 from bup.helpers import add_error, mkdirp, log, is_superuser, format_filesize
 from bup.io import path_msg
index 5edf88ecf892ffe27e8f1bddfc2dc7ba99f0a343..a18981da8afd3cbb596f1736c27a1d155833840f 100644 (file)
@@ -1,6 +1,6 @@
 
 from __future__ import absolute_import, print_function
-import glob, mmap, os, struct
+import glob, os, struct
 
 from bup import _helpers
 from bup.compat import range
index a5b6d8b0876bc4a68784bf1ecc723d3d41cb959c..a41c4429203be2d46c907d43f9da407a31ddd0ac 100644 (file)
@@ -1,6 +1,6 @@
 
 from __future__ import absolute_import, print_function
-import os, pwd, grp
+import os
 
 from bup import _helpers
 from bup.helpers import cache_key_value
index b1f7889870661f2ebece466ae702dd136b970c8f..844bdf1509b340e36a3116aef739dfb226fcd8d2 100644 (file)
@@ -1,11 +1,10 @@
 
 from __future__ import absolute_import
 from binascii import hexlify, unhexlify
-import sys
 
 from bup import compat, git, vfs
 from bup.client import ClientError
-from bup.compat import add_ex_ctx, add_ex_tb, hexstr, pending_raise
+from bup.compat import hexstr, pending_raise
 from bup.git import get_commit_items
 from bup.helpers import add_error, die_if_errors, log, saved_errors
 from bup.io import path_msg
index 2d539e8a32e0084e911d39daff7d8c219c2245ef..b6352293b54a642d47ce11e1d13c24cb889f9b54 100644 (file)
@@ -5,7 +5,7 @@ Connect to a remote host via SSH and execute a command on the host.
 from __future__ import absolute_import, print_function
 import sys, os, re, subprocess
 
-from bup import helpers, path
+from bup import path
 from bup.compat import environ
 
 def connect(rhost, port, subcmd, stderr=None):
index 277a839c4802f899d7e528adc24b45db12cd8c18..df1ccaf9b7d5a0e982fa9d20408fa5596b3f5e76 100644 (file)
@@ -1,8 +1,6 @@
 
 from __future__ import absolute_import, print_function
 
-from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE, GIT_MODE_SYMLINK
-
 
 class TreeItem:
     __slots__ = 'name', 'mode', 'gitmode', 'oid', 'meta'
index 967702ee7ab40d0ca5826a448e5a8dd1ec803a4c..b19f905c9e4ec4d11fd44d3957994bbf65cc093a 100644 (file)
@@ -1,6 +1,5 @@
 
 from __future__ import absolute_import, print_function
-import sys
 
 from bup.compat import ModuleNotFoundError
 
index 9c8b9b4b0b05fceaab46ff28b4176f727768754f..015209d7a5b13257f3bb514857a1dade0e9b8b48 100644 (file)
@@ -49,16 +49,16 @@ item.coid.
 from __future__ import absolute_import, print_function
 from binascii import hexlify, unhexlify
 from collections import namedtuple
-from errno import EINVAL, ELOOP, ENOENT, ENOTDIR
-from itertools import chain, dropwhile, groupby, tee
+from errno import EINVAL, ELOOP, ENOTDIR
+from itertools import chain, groupby, tee
 from random import randrange
 from stat import S_IFDIR, S_IFLNK, S_IFREG, S_ISDIR, S_ISLNK, S_ISREG
 from time import localtime, strftime
 import re, sys
 
-from bup import git, metadata, vint
+from bup import git, vint
 from bup.compat import hexstr, range
-from bup.git import BUP_CHUNKED, cp, get_commit_items, parse_commit, tree_decode
+from bup.git import BUP_CHUNKED, parse_commit, tree_decode
 from bup.helpers import debug2, last
 from bup.io import path_msg
 from bup.metadata import Metadata
index fd8a8f0b369a2da24dc329fe0d76b64fe45bbe27..8179f53b2d55108328b3a41d0e0d7c0e245b2e45 100644 (file)
@@ -9,7 +9,6 @@
 
 from __future__ import absolute_import
 from io import BytesIO
-import sys
 
 from bup import compat
 from bup import _helpers
diff --git a/pylint b/pylint
new file mode 100755 (executable)
index 0000000..c04af78
--- /dev/null
+++ b/pylint
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Changes here might also be appropriate for ./pytest
+
+set -eu
+
+script_home="$(cd "$(dirname "$0")" && pwd -P)"
+testlibdir="$script_home/test/lib"
+
+export PYTHONPATH="$testlibdir${PYTHONPATH:+:$PYTHONPATH}"
+
+if test "$#" -eq 0; then
+    set -x
+    dev/bup-python -m pylint lib
+    # unused-wildcard-import: we always "import * from wvpytest"
+    dev/bup-python -m pylint -d unused-wildcard-import test/lib test/int
+else
+    set -x
+    exec dev/bup-python -m pylint "$@"
+fi
diff --git a/pytest b/pytest
index f35f626bdfe29855de3f9a9f3749424658399e47..d64d766aada01e57f0d34140b408aa21b8876981 100755 (executable)
--- a/pytest
+++ b/pytest
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+# Changes here might also be appropriate for ./pylint
+
 set -eu
 
 script_home="$(cd "$(dirname "$0")" && pwd -P)"
index 69a5e4600eef827018e15a140b6930b8830761b1..5f75d7e6f1e70252843674b064796a4a51552f47 100644 (file)
@@ -5,7 +5,6 @@ import errno, platform, tempfile
 import logging
 
 from bup import bloom
-from bup.helpers import mkdirp
 
 def test_bloom(tmpdir):
     hashes = [os.urandom(20) for i in range(100)]
index f5199ec61b68c84a7c73982f4ed64f74c984de69..b3cdba4bc29fde4227cd3aad22245d5306e28f9d 100644 (file)
@@ -1,11 +1,10 @@
 
 from __future__ import absolute_import
-import sys, os, stat, time, random, subprocess, glob
+import os, time, random, subprocess, glob
 import pytest
 
 from bup import client, git, path
 from bup.compat import bytes_from_uint, environ, range
-from bup.helpers import mkdirp
 
 def randbytes(sz):
     s = b''
index 95e8671de2ef1267ab40f8e501409918137871a6..7965c60ce2314ab2105aa20c1ab405fa68e47720 100644 (file)
@@ -4,7 +4,7 @@ import sys
 from binascii import hexlify, unhexlify
 from subprocess import check_call
 from functools import partial
-import struct, os, time
+import struct, os
 import pytest
 
 from wvpytest import *
index 8bfea77f35ca5e59e2886dba849df4a18bdfdc23..82469a90d5e6065510c5a4df456be7b5df0ebb9c 100644 (file)
@@ -1,18 +1,17 @@
 
 from __future__ import absolute_import
 from time import tzset
-import math, os, os.path, re, subprocess
+import os, os.path, re
 from bup import helpers
 
 from wvpytest import *
 
 from bup.compat import bytes_from_byte, bytes_from_uint, environ
 from bup.helpers import (atomically_replaced_file, batchpipe, detect_fakeroot,
-                         grafted_path_components, mkdirp, parse_num,
+                         grafted_path_components, parse_num,
                          path_components, readpipe, stripped_path_components,
                          shstr,
                          utc_offset_str)
-import bup._helpers as _helpers
 
 
 def test_parse_num():
index 1ab4828d15ea03f56baa7125d60ccd4bdd68ddc9..d00260ea388e0cb18ceeb6cee0fe6642902b3a4b 100644 (file)
@@ -6,7 +6,7 @@ from wvpytest import *
 
 from bup import index, metadata
 from bup.compat import fsencode
-from bup.helpers import mkdirp, resolve_parent
+from bup.helpers import resolve_parent
 import bup.xstat as xstat
 
 
index 62d15c9dde61c970465ca12b94663c5c7132245e..fd3a00c54650c97383513a204303b7a7994ff00d 100644 (file)
@@ -1,6 +1,6 @@
 
 from __future__ import absolute_import, print_function
-import errno, glob, grp, pwd, stat, tempfile, subprocess
+import errno, glob, stat, subprocess
 import os, sys
 import pytest
 
@@ -263,8 +263,6 @@ def test_restore_over_existing_target(tmpdir):
     WVEXCEPT(Exception, dir_m.create_path, path, create_symlinks=True)
 
 
-from bup.metadata import read_acl
-
 from bup.metadata import xattr
 if xattr:
     def remove_selinux(attrs):
index cf66eb32d3547a1266152c7d29f8a5221bde9209..c9a222a88c221efcf838d720faaef0f84a5fbea7 100644 (file)
@@ -4,7 +4,6 @@ from binascii import unhexlify
 from errno import ELOOP, ENOTDIR
 from os import symlink
 from stat import S_IFDIR
-from sys import stderr
 import os
 from time import localtime, strftime
 
@@ -12,8 +11,6 @@ from wvpytest import *
 
 from bup import git, path, vfs
 from bup.compat import environ
-from bup.io import path_msg
-from bup.metadata import Metadata
 from bup.repo import LocalRepo, RemoteRepo
 from buptest import ex, exo
 from buptest.vfs import tree_dict
index 8c3e92720b260152164c9a10db347526bd07b883..f9b3f65ccd441d0f606860af365dcd61170b99b7 100644 (file)
@@ -1,8 +1,6 @@
 
 from __future__ import absolute_import, print_function
 from binascii import unhexlify
-from collections import namedtuple
-from errno import ELOOP, ENOTDIR
 from io import BytesIO
 from os import symlink
 from random import Random, randint
@@ -17,7 +15,6 @@ from wvpytest import *
 from bup._helpers import write_random
 from bup import git, metadata, vfs
 from bup.compat import environ, fsencode, items, range
-from bup.git import BUP_CHUNKED
 from bup.helpers import exc, shstr
 from bup.metadata import Metadata
 from bup.repo import LocalRepo
index b35a57f53bb6be1a037994aa5d99f7e3752e5ced..660a231f1f96c2eb3e83a8b966510d35d140f80e 100644 (file)
@@ -1,6 +1,5 @@
 
 from __future__ import absolute_import
-import math, tempfile, subprocess
 
 from wvpytest import *