.pylintrc | 2 ++
lib/bup/client.py | 7 +++----
lib/bup/cmd/bloom.py | 2 +-
lib/bup/cmd/cat_file.py | 4 ++--
lib/bup/cmd/daemon.py | 10 +++++-----
lib/bup/cmd/damage.py | 2 +-
lib/bup/cmd/drecurse.py | 4 ++--
lib/bup/cmd/features.py | 4 +++-
lib/bup/cmd/fsck.py | 2 +-
lib/bup/cmd/ftp.py | 6 +++---
lib/bup/cmd/fuse.py | 14 +++++++-------
lib/bup/cmd/gc.py | 2 +-
lib/bup/cmd/get.py | 11 +++++------
lib/bup/cmd/help.py | 2 +-
lib/bup/cmd/import_duplicity.py | 4 ++--
lib/bup/cmd/index.py | 2 +-
lib/bup/cmd/init.py | 2 +-
lib/bup/cmd/join.py | 2 +-
lib/bup/cmd/list_idx.py | 2 +-
lib/bup/cmd/margin.py | 2 +-
lib/bup/cmd/memtest.py | 4 ++--
lib/bup/cmd/midx.py | 4 ++--
lib/bup/cmd/mux.py | 2 +-
lib/bup/cmd/on.py | 2 +-
lib/bup/cmd/on__server.py | 2 +-
lib/bup/cmd/prune_older.py | 6 +++---
lib/bup/cmd/random.py | 2 +-
lib/bup/cmd/restore.py | 2 +-
lib/bup/cmd/rm.py | 2 +-
lib/bup/cmd/save.py | 6 +++---
lib/bup/cmd/server.py | 2 +-
lib/bup/cmd/split.py | 6 +++---
lib/bup/cmd/tag.py | 2 +-
lib/bup/cmd/tick.py | 4 +---
lib/bup/cmd/validate_object_links.py | 2 +-
lib/bup/cmd/validate_ref_links.py | 2 +-
lib/bup/cmd/validate_refs.py | 8 ++++----
lib/bup/cmd/version.py | 5 +++--
lib/bup/cmd/web.py | 12 ++++++------
lib/bup/cmd/xstat.py | 5 +----
lib/bup/git.py | 21 +++++++++++----------
lib/bup/helpers.py | 14 ++++++++------
lib/bup/hlinkdb.py | 3 +--
lib/bup/index.py | 3 +--
lib/bup/io.py | 2 +-
lib/bup/ls.py | 4 ++--
lib/bup/metadata.py | 2 +-
lib/bup/protocol.py | 11 +++++------
lib/bup/repo/local.py | 3 ++-
lib/bup/rewrite.py | 2 +-
lib/bup/rm.py | 5 ++---
lib/bup/tree.py | 2 +-
lib/bup/vfs.py | 10 +++++-----
test/int/test_commit.py | 1 +
test/int/test_hashsplit.py | 6 ++----
test/int/test_midx.py | 2 --
test/int/test_resolve.py | 12 ++++++------
test/int/test_vfs.py | 9 ++++-----
58 files changed, 136 insertions(+), 142 deletions(-)
diff --git a/.pylintrc b/.pylintrc
index 788e53de..c3d4b4a5 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -6,6 +6,7 @@ class-rgx=([_a-z]+)|(_?([A-Z]+[a-z]*)+) # LocalRepo mmap finalized...
const-rgx=([_a-z]+)|([_A-Z]+) # snake-case uppper or lower
[VARIABLES]
+dummy-variables-rgx=.*_$
ignored-argument-names=.*_$
[MESSAGES CONTROL]
@@ -65,6 +66,7 @@ enable=
unspecified-encoding,
unused-argument,
unused-import,
+ unused-variable,
unused-wildcard-import,
use-dict-literal,
use-implicit-booleaness-not-len,
diff --git a/lib/bup/client.py b/lib/bup/client.py
index 11547ed8..dcfc74bd 100644
--- a/lib/bup/client.py
+++ b/lib/bup/client.py
@@ -145,7 +145,7 @@ def parse_remote(remote):
def _legacy_cache_id(remote):
- scheme, host, port, path = parse_remote(remote)
+ scheme_, host, port_, path = parse_remote(remote)
# The b'None' here matches python2's behavior of b'%s' % None == 'None',
# python3 will (as of version 3.7.5) do the same for str ('%s' % None),
# but crashes instead when doing b'%s' % None.
@@ -354,11 +354,10 @@ class Client:
yield idx, load
def list_indexes(self):
- for idx, load in self._list_indexes(self):
+ for idx, _ in self._list_indexes(self):
yield idx
def sync_indexes(self):
- conn = self.conn
mkdirp(self.cachedir)
# All cached idxs are extra until proven otherwise
extra = set()
@@ -567,7 +566,7 @@ class Client:
arg = b'%d' % ((1 if want_meta else 0)
| (2 if follow else 0)
| (4 if parent else 0))
- with self._call('resolve', arg) as call:
+ with self._call('resolve', arg):
conn = self.conn
if parent:
protocol.write_resolution(conn, parent)
diff --git a/lib/bup/cmd/bloom.py b/lib/bup/cmd/bloom.py
index 99d9dbd9..c0e44bc2 100644
--- a/lib/bup/cmd/bloom.py
+++ b/lib/bup/cmd/bloom.py
@@ -157,7 +157,7 @@ def do_bloom(path, outfilename, k, force):
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if extra:
o.fatal('no positional parameters expected')
diff --git a/lib/bup/cmd/cat_file.py b/lib/bup/cmd/cat_file.py
index d5cd6c25..0feec430 100644
--- a/lib/bup/cmd/cat_file.py
+++ b/lib/bup/cmd/cat_file.py
@@ -17,7 +17,7 @@ bupm print the target directory's .bupm file directly to stdout
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
git.check_repo_or_die()
@@ -35,7 +35,7 @@ def main(argv):
with LocalRepo() as repo:
resolved = vfs.resolve(repo, target, follow=False)
- leaf_name, leaf_item = resolved[-1]
+ leaf_item = resolved[-1][1]
if not leaf_item:
log('error: cannot access %r in %r\n'
% (b'/'.join(name for name, item in resolved), target))
diff --git a/lib/bup/cmd/daemon.py b/lib/bup/cmd/daemon.py
index d1446491..c805cf9e 100644
--- a/lib/bup/cmd/daemon.py
+++ b/lib/bup/cmd/daemon.py
@@ -18,7 +18,7 @@ p,port port to listen on, defaults to 1982
def main(argv):
o = options.Options(optspec, optfunc=getopt.getopt)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
host = opt.listen
port = int(opt.port) if opt.port else 1982
@@ -26,10 +26,10 @@ def main(argv):
e = None
for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
- af, socktype, proto, canonname, sa = res
+ af, socktype, proto, canonname_, sa = res
try:
s = socket.socket(af, socktype, proto)
- except socket.error as e:
+ except socket.error:
continue
try:
if af == socket.AF_INET6:
@@ -40,7 +40,7 @@ def main(argv):
s.bind(sa)
s.listen(1)
fcntl.fcntl(s.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
- except socket.error as e:
+ except socket.error:
s.close()
continue
socks.append(s)
@@ -51,7 +51,7 @@ def main(argv):
try:
while True:
- [rl,wl,xl] = select.select(socks, [], [], 60)
+ rl = select.select(socks, [], [], 60)[0]
for l in rl:
s, src = l.accept()
try:
diff --git a/lib/bup/cmd/damage.py b/lib/bup/cmd/damage.py
index c39dcc18..b6298187 100644
--- a/lib/bup/cmd/damage.py
+++ b/lib/bup/cmd/damage.py
@@ -24,7 +24,7 @@ S,seed= random number seed (for repeatable tests)
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if not extra:
o.fatal('filenames expected')
diff --git a/lib/bup/cmd/drecurse.py b/lib/bup/cmd/drecurse.py
index 733700be..c68bb1b1 100644
--- a/lib/bup/cmd/drecurse.py
+++ b/lib/bup/cmd/drecurse.py
@@ -39,9 +39,9 @@ def main(argv):
import cProfile # pylint: disable=import-outside-toplevel
cProfile.runctx('for _ in it: pass', globals(), locals())
elif opt.quiet:
- for i in it: pass
+ for _ in it: pass
else:
sys.stdout.flush()
out = byte_stream(sys.stdout)
- for (name,st) in it:
+ for name, st_ in it:
out.write(name + b'\n')
diff --git a/lib/bup/cmd/features.py b/lib/bup/cmd/features.py
index 41627a0b..ddd951fb 100644
--- a/lib/bup/cmd/features.py
+++ b/lib/bup/cmd/features.py
@@ -15,7 +15,9 @@ bup features
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
+ if extra:
+ o.fatal('expected no arguments')
sys.stdout.flush()
out = byte_stream(sys.stdout)
diff --git a/lib/bup/cmd/fsck.py b/lib/bup/cmd/fsck.py
index 9e5918ed..14963129 100644
--- a/lib/bup/cmd/fsck.py
+++ b/lib/bup/cmd/fsck.py
@@ -311,7 +311,7 @@ def main(argv):
global opt, par2_ok
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
opt.verbose = opt.verbose or 0
par2_setup()
diff --git a/lib/bup/cmd/ftp.py b/lib/bup/cmd/ftp.py
index f5bbc84d..1165be03 100644
--- a/lib/bup/cmd/ftp.py
+++ b/lib/bup/cmd/ftp.py
@@ -27,7 +27,7 @@ def do_ls(repo, pwd, args, out):
pwd_str = b'/'.join(name for name, item in pwd) or b'/'
try:
opt = ls.opts_from_cmdline(args, onabort=OptionError, pwd=pwd_str)
- except OptionError as e:
+ except OptionError:
return None
return ls.within_repo(repo, opt, out, pwd_str)
@@ -202,7 +202,7 @@ def present_interface(stdin, out, extra, repo):
if fnmatch.fnmatch(name, base):
if stat.S_ISLNK(vfs.item_mode(item)):
deref = vfs.resolve(repo, name, parent=res)
- deref_name, deref_item = deref[-1]
+ deref_item = deref[-1][1]
if not deref_item:
raise CommandError('path does not exist: '
+ rpath_msg(res))
@@ -227,7 +227,7 @@ def main(argv):
global repo
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
git.check_repo_or_die()
sys.stdout.flush()
diff --git a/lib/bup/cmd/fuse.py b/lib/bup/cmd/fuse.py
index a5295713..83270ffb 100644
--- a/lib/bup/cmd/fuse.py
+++ b/lib/bup/cmd/fuse.py
@@ -57,7 +57,7 @@ class BupFs(fuse.Fuse):
log('--getattr(%r)\n' % path)
res = vfs.resolve(self.repo, path, want_meta=(not self.fake_metadata),
follow=False)
- name, item = res[-1]
+ item = res[-1][1]
if not item:
return -errno.ENOENT
if self.fake_metadata:
@@ -81,12 +81,12 @@ class BupFs(fuse.Fuse):
path = argv_bytes(path)
assert not offset # We don't return offsets, so offset should be unused
res = vfs.resolve(self.repo, path, follow=False)
- dir_name, dir_item = res[-1]
+ dir_item = res[-1][1]
if not dir_item:
yield -errno.ENOENT
yield fuse.Direntry('..')
# FIXME: make sure want_meta=False is being completely respected
- for ent_name, ent_item in vfs.contents(self.repo, dir_item, want_meta=False):
+ for ent_name, ent_item_ in vfs.contents(self.repo, dir_item, want_meta=False):
fusename = fsdecode(ent_name.replace(b'/', b'-'))
yield fuse.Direntry(fusename)
@@ -95,7 +95,7 @@ class BupFs(fuse.Fuse):
if self.verbose > 0:
log('--readlink(%r)\n' % path)
res = vfs.resolve(self.repo, path, follow=False)
- name, item = res[-1]
+ item = res[-1][1]
if not item:
return -errno.ENOENT
return fsdecode(vfs.readlink(self.repo, item))
@@ -105,7 +105,7 @@ class BupFs(fuse.Fuse):
if self.verbose > 0:
log('--open(%r)\n' % path)
res = vfs.resolve(self.repo, path, follow=False)
- name, item = res[-1]
+ item = res[-1][1]
if not item:
return -errno.ENOENT
accmode = os.O_RDONLY | os.O_WRONLY | os.O_RDWR
@@ -121,7 +121,7 @@ class BupFs(fuse.Fuse):
if self.verbose > 0:
log('--read(%r)\n' % path)
res = vfs.resolve(self.repo, path, follow=False)
- name, item = res[-1]
+ item = res[-1][1]
if not item:
return -errno.ENOENT
with vfs.fopen(self.repo, item) as f:
@@ -141,7 +141,7 @@ v,verbose increase log output (can be used more than once)
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if not opt.verbose:
opt.verbose = 0
diff --git a/lib/bup/cmd/gc.py b/lib/bup/cmd/gc.py
index 6653c08e..fec21a35 100644
--- a/lib/bup/cmd/gc.py
+++ b/lib/bup/cmd/gc.py
@@ -19,7 +19,7 @@ unsafe use the command even though it may be DANGEROUS
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if not opt.unsafe:
o.fatal('refusing to run dangerous, experimental command without --unsafe')
diff --git a/lib/bup/cmd/get.py b/lib/bup/cmd/get.py
index 930ed881..0bba34a4 100644
--- a/lib/bup/cmd/get.py
+++ b/lib/bup/cmd/get.py
@@ -345,7 +345,6 @@ def transfer_commit(hash, parent, src_repo, dest_repo, ignore_missing):
items = parse_commit(get_cat_data(
src_repo.cat(hash), b'commit'))
tree = unhexlify(items.tree)
author = b'%s <%s>' % (items.author_name, items.author_mail)
- author_time = (items.author_sec, items.author_offset)
committer = b'%s <%s@%s>' % (userfullname(), username(), hostname())
get_random_item(hexlify(tree), src_repo, dest_repo, ignore_missing)
c = dest_repo.write_commit(tree, parent,
@@ -367,7 +366,7 @@ def append_commit(src_loc, parent, src_repo, dest_repo, rewriter, excludes,
assert isinstance(src_loc, Loc), src_loc
path = src_loc.vfs_path
assert len(path) == 3, path
- root, ref, save = path
+ root_, ref, save = path
assert isinstance(save[1], (vfs.Commit, vfs.FakeLink)), path
assert isinstance(ref[1], vfs.RevList), path
save_oid, tree_oid, repairs = \
@@ -394,8 +393,8 @@ def append_commits(src_loc, dest_hash, src_repo, dest_repo, rewriter, excludes,
assert isinstance(src_loc, Loc), src_loc
assert src_loc.type in ('branch', 'commit', 'save'), src_loc
path = src_loc.vfs_path
- assert len(path) == 2, path
- root, ref = path
+ assert len(path) == 2, path # root, ref
+ ref = path[1]
assert isinstance(ref[1], vfs.RevList), ref[1]
# We need both the VFS name (YYYY-MM-DD[-N]), and the rev-list
@@ -613,9 +612,9 @@ def resolve_append(spec, src_repo, dest_repo):
if not isinstance(src, Loc):
misuse(f'cannot currently rewrite git location {src}')
src_path = src.vfs_path
- if len(src_path) != 2:
+ if len(src_path) != 2: # root, src_ref
misuse(f'cannot append {vpm(src_path)}')
- root, src_ref = src_path
+ src_ref = src_path[1]
if not isinstance(src_ref[1], vfs.RevList):
misuse(f'cannot append {vpm(src_path)} saves'
f' ({path_msg(src_ref[0])} is a {type(src_ref[1])})')
diff --git a/lib/bup/cmd/help.py b/lib/bup/cmd/help.py
index e3f8d531..dbbc4677 100644
--- a/lib/bup/cmd/help.py
+++ b/lib/bup/cmd/help.py
@@ -12,7 +12,7 @@ bup help <command>
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
if len(extra) == 0:
os.execvp(path.exe(), [path.exe(), b'-h'])
diff --git a/lib/bup/cmd/import_duplicity.py b/lib/bup/cmd/import_duplicity.py
index 27de66b2..75b7fbc7 100644
--- a/lib/bup/cmd/import_duplicity.py
+++ b/lib/bup/cmd/import_duplicity.py
@@ -32,7 +32,7 @@ def main(argv):
log('\nbup: import-duplicity is EXPERIMENTAL (proceed with caution)\n\n')
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
dry_run = opt.dry_run
if len(extra) < 1 or not extra[0]:
@@ -68,7 +68,7 @@ def main(argv):
elif line.startswith(b' full '):
assert(len(line) >= len(b' full 20150222T073233Z'))
dup_timestamps.append(line[6:22])
- for i, dup_ts in enumerate(dup_timestamps):
+ for dup_ts in dup_timestamps:
tm = strptime(dup_ts.decode('ascii'), '%Y%m%dT%H%M%SZ')
exc([b'rm', b'-rf', restoredir])
exc(dup + [b'restore', b'-t', dup_ts, source_url, restoredir])
diff --git a/lib/bup/cmd/index.py b/lib/bup/cmd/index.py
index ae171b31..f9a3fea0 100644
--- a/lib/bup/cmd/index.py
+++ b/lib/bup/cmd/index.py
@@ -287,7 +287,7 @@ def main(argv):
excluded_paths = parse_excludes(flags, o.fatal)
exclude_rxs = parse_rx_excludes(flags, o.fatal)
xexcept = index.unique_resolved_paths(extra)
- for rp, path in index.reduce_paths(extra):
+ for rp, path_ in index.reduce_paths(extra):
update_index(rp, excluded_paths, exclude_rxs, fsindex,
check=opt.check, check_device=opt.check_device,
xdev=opt.xdev, xdev_exceptions=xexcept,
diff --git a/lib/bup/cmd/init.py b/lib/bup/cmd/init.py
index d5d31412..d187c7fa 100644
--- a/lib/bup/cmd/init.py
+++ b/lib/bup/cmd/init.py
@@ -16,7 +16,7 @@ r,remote= remote repository path
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if opt.remote: opt.remote = argv_bytes(opt.remote)
if len(extra) > 1:
o.fatal('only the directory positional argument is allowed')
diff --git a/lib/bup/cmd/join.py b/lib/bup/cmd/join.py
index 1d5a6c0f..2a5e798b 100644
--- a/lib/bup/cmd/join.py
+++ b/lib/bup/cmd/join.py
@@ -19,7 +19,7 @@ o= output filename
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
addr = derive_repo_addr(remote=argv_bytes(opt.remote) if opt.remote else None,
die=o.fatal)
diff --git a/lib/bup/cmd/list_idx.py b/lib/bup/cmd/list_idx.py
index b72e6e13..33dbd831 100644
--- a/lib/bup/cmd/list_idx.py
+++ b/lib/bup/cmd/list_idx.py
@@ -15,7 +15,7 @@ find= display only objects that start with <prefix>
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
handle_ctrl_c()
diff --git a/lib/bup/cmd/margin.py b/lib/bup/cmd/margin.py
index 5e78026b..86e0c88b 100644
--- a/lib/bup/cmd/margin.py
+++ b/lib/bup/cmd/margin.py
@@ -16,7 +16,7 @@ ignore-midx Don't use midx files; use only plain pack idx files.
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if extra:
o.fatal("no arguments expected")
diff --git a/lib/bup/cmd/memtest.py b/lib/bup/cmd/memtest.py
index b2049673..ae5bb6af 100644
--- a/lib/bup/cmd/memtest.py
+++ b/lib/bup/cmd/memtest.py
@@ -71,7 +71,7 @@ existing test with existing objects instead of fake ones
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if extra:
o.fatal('no arguments expected')
@@ -94,7 +94,7 @@ def main(argv):
objit = iter(foreverit(m))
for c in range(opt.cycles):
- for n in range(opt.number):
+ for _ in range(opt.number):
if opt.existing:
bin = next(objit)
assert(m.exists(bin))
diff --git a/lib/bup/cmd/midx.py b/lib/bup/cmd/midx.py
index a97c4605..1663b66b 100644
--- a/lib/bup/cmd/midx.py
+++ b/lib/bup/cmd/midx.py
@@ -173,7 +173,7 @@ def _do_midx(outdir, outfilename, infilenames, prefixstr,
fsync(f.fileno())
with mmap_readwrite(f, close=False) as fmap:
- count = merge_into(fmap, bits, total, inp)
+ merge_into(fmap, bits, total, inp)
f.seek(0, os.SEEK_END)
f.write(b'\0'.join(allfilenames))
f.flush()
@@ -283,7 +283,7 @@ def do_midx_group(outdir, outfilename, infiles, auto=False, force=False,
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
opt.output = argv_bytes(opt.output) if opt.output else None
if extra and (opt.auto or opt.force):
diff --git a/lib/bup/cmd/mux.py b/lib/bup/cmd/mux.py
index a8ebd3b9..5c0306aa 100644
--- a/lib/bup/cmd/mux.py
+++ b/lib/bup/cmd/mux.py
@@ -19,7 +19,7 @@ def main(argv):
os.close(devnull)
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
if len(extra) < 1:
o.fatal('command is required')
diff --git a/lib/bup/cmd/on.py b/lib/bup/cmd/on.py
index 4e40294c..179cb3c3 100644
--- a/lib/bup/cmd/on.py
+++ b/lib/bup/cmd/on.py
@@ -17,7 +17,7 @@ bup on <[user@]host[:port]> <index|save|split|get> ...
def main(argv):
o = options.Options(optspec, optfunc=getopt.getopt)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
if len(extra) < 2:
o.fatal('must specify index, save, split, or get command')
diff --git a/lib/bup/cmd/on__server.py b/lib/bup/cmd/on__server.py
index b9aad484..992d5516 100644
--- a/lib/bup/cmd/on__server.py
+++ b/lib/bup/cmd/on__server.py
@@ -13,7 +13,7 @@ bup on--server
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
if extra:
o.fatal('no arguments expected')
diff --git a/lib/bup/cmd/prune_older.py b/lib/bup/cmd/prune_older.py
index d04a8727..ff2f3c85 100644
--- a/lib/bup/cmd/prune_older.py
+++ b/lib/bup/cmd/prune_older.py
@@ -48,7 +48,7 @@ def classify_saves(saves, period_start):
# each group, and a "drop" action (False, utc) for the rest.
for pstart, time_region_id in tm_ranges:
matches, rest = partition(lambda s: s[0] >= pstart, rest)
- for region_id, region_saves in groupby(matches, time_region_id):
+ for region_id_, region_saves in groupby(matches, time_region_id):
yield from retain_newest_in_region(list(region_saves))
# Finally, drop any saves older than the specified periods
@@ -74,7 +74,7 @@ unsafe use the command even though it may be DANGEROUS
def main(argv):
o = options.Options(optspec)
- opt, flags, roots = o.parse_bytes(argv[1:])
+ opt, flags_, roots = o.parse_bytes(argv[1:])
roots = [argv_bytes(x) for x in roots]
if not opt.unsafe:
@@ -111,7 +111,7 @@ def main(argv):
try:
when = strftime('%Y-%m-%d-%H%M%S', localtime(period_utc))
log('keeping ' + kind + ' since ' + when + '\n')
- except ValueError as ex:
+ except ValueError:
if period_utc < 0:
log('keeping %s since %d seconds before %s\n'
%(kind, abs(period_utc), epoch_ymd))
diff --git a/lib/bup/cmd/random.py b/lib/bup/cmd/random.py
index dc8931d8..1d571f4e 100644
--- a/lib/bup/cmd/random.py
+++ b/lib/bup/cmd/random.py
@@ -15,7 +15,7 @@ v,verbose print byte counter to stderr
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if len(extra) != 1:
o.fatal("exactly one argument expected")
diff --git a/lib/bup/cmd/restore.py b/lib/bup/cmd/restore.py
index 6be39f8e..f619daf9 100644
--- a/lib/bup/cmd/restore.py
+++ b/lib/bup/cmd/restore.py
@@ -264,7 +264,7 @@ def main(argv):
# Rename it back to 'latest'
resolved = tuple(elt if i != 2 else (b'latest',) + elt[1:]
for i, elt in enumerate(resolved))
- path_parent, path_name = os.path.split(path)
+ path_name = os.path.split(path)[1]
leaf_name, leaf_item = resolved[-1]
if not leaf_item:
add_error('error: cannot access %r in %r'
diff --git a/lib/bup/cmd/rm.py b/lib/bup/cmd/rm.py
index 3f870c8c..91c916f0 100644
--- a/lib/bup/cmd/rm.py
+++ b/lib/bup/cmd/rm.py
@@ -16,7 +16,7 @@ unsafe use the command even though it may be DANGEROUS
def main(argv):
o = Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if not opt.unsafe:
o.fatal('refusing to run dangerous, experimental command without --unsafe')
diff --git a/lib/bup/cmd/save.py b/lib/bup/cmd/save.py
index 07e76fe6..175aeaf6 100644
--- a/lib/bup/cmd/save.py
+++ b/lib/bup/cmd/save.py
@@ -208,8 +208,8 @@ def save_tree(opt, reader, hlink_db, msr, repo, split_cfg):
assert 'progress' not in split_cfg
split_cfg['progress'] = progress_report
- for transname, ent in reader.filter(opt.sources,
- wantrecurse=wantrecurse_pre):
+ for transname_, ent in reader.filter(opt.sources,
+ wantrecurse=wantrecurse_pre):
if not (ftotal % 10024):
qprogress('Reading index: %d\r' % ftotal)
exists = ent.exists()
@@ -238,7 +238,7 @@ def save_tree(opt, reader, hlink_db, msr, repo, split_cfg):
fcount = 0
lastskip_name = None
lastdir = b''
- for transname, ent in reader.filter(opt.sources,
+ for transname_, ent in reader.filter(opt.sources,
wantrecurse=wantrecurse_during):
(dir, file) = os.path.split(
ent.name)
exists = (ent.flags & index.IX_EXISTS)
diff --git a/lib/bup/cmd/server.py b/lib/bup/cmd/server.py
index 29cba644..01c6f0f6 100644
--- a/lib/bup/cmd/server.py
+++ b/lib/bup/cmd/server.py
@@ -13,7 +13,7 @@ bup server
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
if extra:
o.fatal('no arguments expected')
diff --git a/lib/bup/cmd/split.py b/lib/bup/cmd/split.py
index 17aeacf5..c90e5c0e 100644
--- a/lib/bup/cmd/split.py
+++ b/lib/bup/cmd/split.py
@@ -54,7 +54,7 @@ bwlimit= maximum bytes/sec to transmit to server
def opts_from_cmdline(o, argv):
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
opt.sources = extra
if
opt.name:
opt.name = argv_bytes(
opt.name)
@@ -121,7 +121,7 @@ def split(opt, files, parent, out, split_cfg, *,
if opt.blobs:
shalist = \
split_to_blobs(new_blob, hashsplit.from_config(files, split_cfg))
- for sha, size, level in shalist:
+ for sha, size_, level_ in shalist:
out.write(hexlify(sha) + b'\n')
reprogress()
elif opt.tree or opt.commit or
opt.name:
@@ -137,7 +137,7 @@ def split(opt, files, parent, out, split_cfg, *,
tree = new_tree(shalist)
else:
last = 0
- for blob, level in hashsplit.from_config(files, split_cfg):
+ for blob, level_ in hashsplit.from_config(files, split_cfg):
hashsplit.total_split += len(blob)
if opt.copy:
out.write(blob)
diff --git a/lib/bup/cmd/tag.py b/lib/bup/cmd/tag.py
index 3870ada5..ebb60388 100644
--- a/lib/bup/cmd/tag.py
+++ b/lib/bup/cmd/tag.py
@@ -20,7 +20,7 @@ f,force Overwrite existing tag, or ignore missing tag when deleting
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
git.check_repo_or_die()
diff --git a/lib/bup/cmd/tick.py b/lib/bup/cmd/tick.py
index c3c6f4b3..9135bedf 100644
--- a/lib/bup/cmd/tick.py
+++ b/lib/bup/cmd/tick.py
@@ -10,11 +10,9 @@ bup tick
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
-
+ extra = o.parse_bytes(argv[1:])[2]
if extra:
o.fatal("no arguments expected")
-
t = time.time()
tleft = 1 - (t - int(t))
time.sleep(tleft)
diff --git a/lib/bup/cmd/validate_object_links.py b/lib/bup/cmd/validate_object_links.py
index 1c340a15..660de9d7 100644
--- a/lib/bup/cmd/validate_object_links.py
+++ b/lib/bup/cmd/validate_object_links.py
@@ -75,7 +75,7 @@ class Pack:
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ extra = o.parse_bytes(argv[1:])[2]
if extra:
o.fatal("no arguments expected")
diff --git a/lib/bup/cmd/validate_ref_links.py b/lib/bup/cmd/validate_ref_links.py
index d9c305a1..9fc340d6 100644
--- a/lib/bup/cmd/validate_ref_links.py
+++ b/lib/bup/cmd/validate_ref_links.py
@@ -12,7 +12,7 @@ v,verbose increase log output (can be used more than once)
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
args = [argv[0]]
args.extend([b'-v'] * (opt.verbose or 0))
args.append(b'--links')
diff --git a/lib/bup/cmd/validate_refs.py b/lib/bup/cmd/validate_refs.py
index b0a98474..85a28f80 100644
--- a/lib/bup/cmd/validate_refs.py
+++ b/lib/bup/cmd/validate_refs.py
@@ -24,12 +24,12 @@ v,verbose increase log output (can be used more than once)
def expected_bup_entry_count_for_tree(tree_data):
exp_n = 1 # for the parent dir
- for mode, mangled_name, oid in tree_iter(tree_data):
+ for mode, mangled_name, oid_ in tree_iter(tree_data):
if mangled_name.endswith(b'.bupd'):
return 2
if mangled_name == b'.bupm':
continue
- name, kind = demangle_name(mangled_name, mode)
+ kind = demangle_name(mangled_name, mode)[1]
if S_ISDIR(mode) and kind != BUP_CHUNKED:
continue
exp_n += 1
@@ -60,7 +60,7 @@ def resolve_refs(repo, refs, fatal):
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
verbosity = opt.verbose
if (opt.links, opt.bupm) == (False, False):
@@ -134,7 +134,7 @@ def main(argv):
if opt.links:
idxl = git.PackIdxList(git.repo(b'objects/pack'))
maybe_close_idxl.enter_context(idxl)
- live_objs, live_trees = \
+ live_objs, live_trees_ = \
find_live_objects(existing_count, cat_pipe,
refs=ref_info,
idx_list=idxl,
diff --git a/lib/bup/cmd/version.py b/lib/bup/cmd/version.py
index 032d1c79..d42910db 100644
--- a/lib/bup/cmd/version.py
+++ b/lib/bup/cmd/version.py
@@ -15,8 +15,9 @@ commit display the git commit id of this version of bup
def main(argv):
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
-
+ opt, flags_, extra = o.parse_bytes(argv[1:])
+ if extra:
+ o.fatal('arguments not expected')
total = (opt.date or 0) + (opt.commit or 0)
if total > 1:
diff --git a/lib/bup/cmd/web.py b/lib/bup/cmd/web.py
index 8b909db9..86ff1a2c 100644
--- a/lib/bup/cmd/web.py
+++ b/lib/bup/cmd/web.py
@@ -118,7 +118,7 @@ def _contains_hidden_files(repo, dir_item):
'.' and '..' that begin with '.'
"""
- for name, item in vfs.contents(repo, dir_item, want_meta=False):
+ for name, item_ in vfs.contents(repo, dir_item, want_meta=False):
if name in (b'.', b'..'):
continue
if name.startswith(b'.'):
@@ -211,7 +211,7 @@ class BupRequestHandler(tornado.web.RequestHandler):
# Set want_meta because dir metadata won't be fetched, and if
# it's not a dir, then we're going to want the metadata.
res = vfs.resolve(self.repo, path, want_meta=True)
- leaf_name, leaf_item = res[-1]
+ leaf_item = res[-1][1]
if not leaf_item:
self.send_error(404)
return
@@ -309,7 +309,7 @@ class BupRequestHandler(tornado.web.RequestHandler):
as a default; however it would be permissible (if
slow) to look inside the data to make a better guess.
"""
- base, ext = posixpath.splitext(path)
+ ext = posixpath.splitext(path)[1]
if ext in self.extensions_map:
return self.extensions_map[ext]
ext = ext.lower()
@@ -360,7 +360,7 @@ def main(argv):
InetAddress = namedtuple('InetAddress', ['host', 'port'])
o = options.Options(optspec)
- opt, flags, extra = o.parse_bytes(argv[1:])
+ opt, flags_, extra = o.parse_bytes(argv[1:])
if len(extra) > 1:
o.fatal("at most one argument expected")
@@ -380,8 +380,8 @@ def main(argv):
host, port = addr_parts
try:
port = int(port)
- except (TypeError, ValueError) as ex:
- o.fatal('port must be an integer, not %r' % port)
+ except ValueError:
+ o.fatal(f'port {path_msg(port)} is not an integer')
address = InetAddress(host=host, port=port)
git.check_repo_or_die()
diff --git a/lib/bup/cmd/xstat.py b/lib/bup/cmd/xstat.py
index 7872a626..b0ee8ec9 100644
--- a/lib/bup/cmd/xstat.py
+++ b/lib/bup/cmd/xstat.py
@@ -41,10 +41,6 @@ ctime-resolution= limit s, ms, us, ns, 10ns (value must be a power of 10) [ns]
"""
def main(argv):
-
- target_filename = b''
- active_fields = metadata.all_fields
-
o = options.Options(optspec)
(opt, flags, remainder) = o.parse_bytes(argv[1:])
@@ -52,6 +48,7 @@ def main(argv):
mtime_resolution = parse_timestamp_arg(o, 'mtime', opt.mtime_resolution)
ctime_resolution = parse_timestamp_arg(o, 'ctime', opt.ctime_resolution)
+ active_fields = metadata.all_fields
treat_include_fields_as_definitive = True
for flag, value in flags:
if flag == '--exclude-fields':
diff --git a/lib/bup/git.py b/lib/bup/git.py
index ee50822a..20170e80 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -219,12 +219,11 @@ def calc_hash(type, content):
def shalist_item_sort_key(ent):
- (mode, name, id) = ent
- assert(mode+0 == mode)
+ mode = ent[0] # mode, name, oid
+ assert isinstance(mode, int), oct(mode)
if stat.S_ISDIR(mode):
- return name + b'/'
- else:
- return name
+ return ent[1] + b'/'
+ return ent[1]
def tree_encode(shalist):
@@ -668,7 +667,7 @@ class PackIdxList:
if not missing:
if mx: midxl.append(mx)
else:
- mxd, mxf = os.path.split(full)
+ mxf = os.path.split(full)[1]
for n in missing:
log(('warning: index %s missing\n'
' used by %s\n')
@@ -809,7 +808,7 @@ class LocalPackStore():
def _open(self):
if not self._file:
with ExitStack() as err_stack:
- objdir = dir = os.path.join(self._repo_dir, b'objects')
+ objdir = os.path.join(self._repo_dir, b'objects')
self._tmpdir = err_stack.enter_context(temp_dir(dir=objdir, prefix=b'pack-tmp-'))
self._file = err_stack.enter_context(open(self._tmpdir + b'/pack', 'w+b'))
self._parentfd = err_stack.enter_context(finalized(os.open(objdir, os.O_RDONLY),
@@ -930,8 +929,10 @@ class PackWriter:
log('>')
assert sha
encoded = _encode_packobj(type, content, self.compression_level)
- size, crc = self._store.write(encoded, sha=sha)
- self._byte_count += sum(len(x) for x in encoded)
+ size, crc_ = self._store.write(encoded, sha=sha)
+ exp_size = sum(len(x) for x in encoded)
+ assert exp_size == size, f'unexpected: {exp_size} != {size} {crc_}'
+ self._byte_count += exp_size
self._obj_count += 1
if self._byte_count >= self.max_pack_size \
or self._obj_count >= self.max_pack_objects:
@@ -1272,7 +1273,7 @@ def establish_default_repo(path=None, *, must_exist=False):
except FileNotFoundError:
pass
try:
- top_st = os.stat(top)
+ os.stat(top)
except NotADirectoryError:
return maybe_exit(15, f'{path_msg(top)} is not a repository\n')
except FileNotFoundError:
diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index 86343eeb..5b487d90 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -499,7 +499,7 @@ class Conn(BaseConn):
return self.inp.readline()
def has_input(self):
- [rl, wl, xl] = select.select([self.inp.fileno()], [], [], 0)
+ rl = select.select([self.inp.fileno()], [], [], 0)[0]
if rl:
assert(rl[0] == self.inp.fileno())
return True
@@ -568,7 +568,7 @@ class DemuxConn(BaseConn):
def _next_packet(self, timeout):
if self.closed: return False
- rl, wl, xl = select.select([self.infd], [], [], timeout)
+ rl = select.select([self.infd], [], [], timeout)[0]
if not rl: return False
assert(rl[0] == self.infd)
ns = b''.join(checked_reader(self.infd, 5))
@@ -948,8 +948,9 @@ def parse_excludes(options, fatal):
elif option == '--exclude-from':
try:
f = open(resolve_parent(argv_bytes(parameter)), 'rb')
- except IOError as e:
- raise fatal("couldn't read %r" % parameter)
+ except OSError as ex:
+ raise fatal(f"couldn't read exclusions from {path_msg(parameter)}"
+ f' ({ex.strerror} [{ex.errno}])')
for exclude_path in f.readlines():
# FIXME: perhaps this should be rstrip('\n')
exclude_path = resolve_parent(exclude_path.strip())
@@ -977,8 +978,9 @@ def parse_rx_excludes(options, fatal):
elif option == b'--exclude-rx-from':
try:
f = open(resolve_parent(parameter), 'rb')
- except IOError as e:
- fatal("couldn't read %r" % parameter)
+ except OSError as ex:
+ raise fatal(f"couldn't read exclusions from {path_msg(parameter)}"
+ f' ({ex.strerror} [{ex.errno}])')
for pattern in f.readlines():
spattern = pattern.rstrip(b'\n')
if not spattern:
diff --git a/lib/bup/hlinkdb.py b/lib/bup/hlinkdb.py
index 9e2f87ba..b71b5501 100644
--- a/lib/bup/hlinkdb.py
+++ b/lib/bup/hlinkdb.py
@@ -1,6 +1,6 @@
from contextlib import ExitStack
-import os, pickle
+import pickle
from bup.helpers import atomically_replaced_file, fsync, unlink
@@ -38,7 +38,6 @@ class HLinkDB:
raise Error('save of %r already in progress' % self._filename)
with self._cleanup:
if self._node_paths:
- dir, name = os.path.split(self._filename)
self._pending_save = atomically_replaced_file(self._filename,
mode='wb',
buffering=65536)
diff --git a/lib/bup/index.py b/lib/bup/index.py
index c79c39e6..7c4d6c9d 100644
--- a/lib/bup/index.py
+++ b/lib/bup/index.py
@@ -400,7 +400,7 @@ class ExistingEntry(Entry):
ofs = self.children_ofs
assert(ofs <= len(self._m))
assert(self.children_n <= UINT_MAX) # i.e. python struct 'I'
- for i in range(self.children_n):
+ for _ in range(self.children_n):
eon = self._m.find(b'\0', ofs)
assert(eon >= 0)
assert(eon >= ofs)
@@ -545,7 +545,6 @@ class Writer:
self.filename = filename = resolve_parent(filename)
self.metastore = metastore
self.tmax = tmax
- (dir,name) = os.path.split(filename)
with ExitStack() as self.cleanup:
self.pending_index = atomically_replaced_file(self.filename,
mode='wb',
diff --git a/lib/bup/io.py b/lib/bup/io.py
index dc626844..844d1c9f 100644
--- a/lib/bup/io.py
+++ b/lib/bup/io.py
@@ -12,7 +12,7 @@ import os, select, sys, time
# leading to race conditions. Ick. We'll do it the hard way.
def _hard_write(fd, buf):
while buf:
- (r,w,x) = select.select([], [fd], [], None)
+ w = select.select([], [fd], [], None)[1]
if not w:
raise IOError('select(fd) returned without being writable')
try:
diff --git a/lib/bup/ls.py b/lib/bup/ls.py
index 2ace8c83..9b47446e 100644
--- a/lib/bup/ls.py
+++ b/lib/bup/ls.py
@@ -93,7 +93,7 @@ def opts_from_cmdline(args, onabort=None, pwd=b'/'):
opt.classification = None
opt.show_hidden = None
for flag in flags:
- option, parameter = flag
+ option, value_ = flag
if option in ('-F', '--classify'):
opt.classification = 'all'
elif option == '--file-type':
@@ -145,7 +145,7 @@ def within_repo(repo, opt, out, pwd=b''):
else:
resolved = vfs.try_resolve(repo, path, want_meta=want_meta)
- leaf_name, leaf_item = resolved[-1]
+ leaf_name_, leaf_item = resolved[-1]
if not leaf_item:
log('error: cannot access %r in %r\n'
% ('/'.join(path_msg(name) for name, item in resolved),
diff --git a/lib/bup/metadata.py b/lib/bup/metadata.py
index 1ca204d0..fb9e17ca 100644
--- a/lib/bup/metadata.py
+++ b/lib/bup/metadata.py
@@ -735,7 +735,7 @@ class Metadata:
xattr_n = vint.read_vuint(memfile)
if xattr_n is None:
raise EOFError('EOF while reading number of Linux xattrs')
- for i in range(xattr_n):
+ for _ in range(xattr_n):
key = vint.read_bvec(memfile)
if key is None:
raise EOFError('EOF while reading Linux xattr metadata key')
diff --git a/lib/bup/protocol.py b/lib/bup/protocol.py
index ddb885f0..7158bf24 100644
--- a/lib/bup/protocol.py
+++ b/lib/bup/protocol.py
@@ -108,7 +108,7 @@ def read_resolution(port):
if n is None:
raise EOFError('EOF while reading VFS resolve path length')
result = []
- for i in range(n):
+ for _ in range(n):
name = read_bvec(port)
if name is None:
raise EOFError('EOF while reading VFS resolve path name')
@@ -193,7 +193,6 @@ class Server:
self.suspended = False
else:
self.repo = self._backend(repo_dir, server=True)
- msgdir = path_msg(self.repo.repo_dir)
dw = self.repo.config_get(b'bup.server.deduplicate-writes', opttype='bool')
self._deduplicate_writes = True if dw is None else dw
debug1('bup server: (%sdeduplicating) serving %s\n'
@@ -263,7 +262,7 @@ class Server:
self.repo._packwriter.object_count() != 1 and "s" or ''))
fullpath = self.repo.finish_writing()
if fullpath:
- dir, name = os.path.split(fullpath)
+ name = os.path.split(fullpath)[1]
self.conn.write(b'%s.idx\n' % name)
self.conn.ok()
return
@@ -285,8 +284,8 @@ class Server:
if result:
oldpack = result.pack
assert(oldpack.endswith(b'.idx'))
- (dir,name) = os.path.split(oldpack)
- if not (name in suggested):
+ name = os.path.split(oldpack)[1]
+ if not name in suggested:
debug1("bup server: suggesting index %s\n"
% git.shorten_hash(name).decode('ascii'))
debug1("bup server: because of object %s\n"
@@ -296,7 +295,7 @@ class Server:
continue
# FIXME: figure out the right abstraction for this; or better yet,
# make the protocol aware of the object type
- nw, crc = self.repo._packwriter._store.write((buf,), sha=shar)
+ crc = self.repo._packwriter._store.write((buf,), sha=shar)[1]
self._check(crcr, crc, 'object read: expected crc %d, got %d\n')
assert False # should be unreachable
diff --git a/lib/bup/repo/local.py b/lib/bup/repo/local.py
index 84fcdcbd..f4b5d7e7 100644
--- a/lib/bup/repo/local.py
+++ b/lib/bup/repo/local.py
@@ -110,7 +110,8 @@ class LocalRepo(RepoProtocol):
def cat(self, ref):
it = self._cp.get(ref)
- oidx, typ, size = info = next(it)
+ info = next(it)
+ oidx = info[0]
yield info
if oidx: yield from it
assert not next(it, None)
diff --git a/lib/bup/rewrite.py b/lib/bup/rewrite.py
index 49456f38..eec972f1 100755
--- a/lib/bup/rewrite.py
+++ b/lib/bup/rewrite.py
@@ -430,7 +430,7 @@ def _rewrite_save_item(path, replacement_dir, srcrepo, dstrepo, split_cfg,
# push/pop it, just add the previously generated tree to
# the parent.
extend_stack(dir_path[len(stack):-1]) # establish the parent
- dir_name, dir_item = dir_path[-1]
+ dir_name, dir_item_ = dir_path[-1]
stack.append_to_current(dir_name, GIT_MODE_TREE, GIT_MODE_TREE,
replacement_dir, None)
return
diff --git a/lib/bup/rm.py b/lib/bup/rm.py
index 4227ed73..9e210f3e 100644
--- a/lib/bup/rm.py
+++ b/lib/bup/rm.py
@@ -23,18 +23,17 @@ def filter_branch(tip_commit_hex, exclude, writer):
# May return None if everything is excluded.
commits = [unhexlify(x) for x in git.rev_list(tip_commit_hex)]
commits.reverse()
- last_c, tree = None, None
+ last_c = None
# Rather than assert that we always find an exclusion here, we'll
# just let the StopIteration signal the error.
first_exclusion = next(i for i, c in enumerate(commits) if exclude(c))
if first_exclusion != 0:
last_c = commits[first_exclusion - 1]
- tree = unhexlify(get_commit_items(hexlify(last_c), git.cp()).tree)
commits = commits[first_exclusion:]
for c in commits:
if exclude(c):
continue
- last_c, tree = append_commit(hexlify(c), last_c, git.cp(), writer)
+ last_c, _ = append_commit(hexlify(c), last_c, git.cp(), writer)
return last_c
def commit_oid(item):
diff --git a/lib/bup/tree.py b/lib/bup/tree.py
index 0d9d8111..6d2cda8b 100644
--- a/lib/bup/tree.py
+++ b/lib/bup/tree.py
@@ -260,7 +260,7 @@ class Stack:
h = RecordHashSplitter(bits=BUP_TREE_BLOBBITS)
for item in items:
pending_split.append(item)
- split, bits = h.feed(
item.name)
+ split = h.feed(
item.name)[0] # [1] is bits
if (split and len(pending_split) > 1) or item is last_item:
splits.append(pending_split)
pending_split = []
diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py
index 4da31052..c54a4137 100644
--- a/lib/bup/vfs.py
+++ b/lib/bup/vfs.py
@@ -170,7 +170,7 @@ def _normal_or_chunked_file_size(repo, oid):
_, obj_t, _, it = get_oidx(repo, hexlify(oid))
ofs = 0
while obj_t == b'tree':
- mode, name, last_oid = last_tree_entry(b''.join(it))
+ mode_, name, last_oid = last_tree_entry(b''.join(it))
ofs += int(name, 16)
_, obj_t, _, it = get_oidx(repo, hexlify(last_oid))
return ofs + sum(len(b) for b in it)
@@ -905,7 +905,7 @@ def parse_rev(f):
return unhexlify(tree), int(auth_sec)
def _item_for_rev(rev):
- commit_oidx, (tree_oid, utc) = rev
+ commit_oidx, (tree_oid, utc_) = rev
coid = unhexlify(commit_oidx)
item = cache_get_commit_item(coid, need_meta=False)
if item:
@@ -1159,7 +1159,7 @@ def _resolve_path(repo, path, parent=None, want_meta=True, follow=True):
else: # First item will be '.' and have the metadata
assert len(items) in (1, 2), items
item = items[1][1] if len(items) == 2 else None
- dot, dot_item = items[0]
+ dot = items[0][0] # items[0][1] is the dot item
assert dot == b'.'
past[-1] = parent_name, parent_item
if not item:
@@ -1281,7 +1281,7 @@ def try_resolve(repo, path, parent=None, want_meta=True):
if not S_ISLNK(item_mode(leaf_item)):
return res
follow = resolve(repo, leaf_name, parent=res[:-1], want_meta=want_meta)
- follow_name, follow_item = follow[-1]
+ follow_item = follow[-1][1] # [0] is the name
if follow_item:
return follow
return res
@@ -1360,7 +1360,7 @@ def join(repo, ref):
if typ == b'blob':
yield from it
elif typ == b'tree':
- for ent_mode, ent_name, ent_oid in tree_iter(b''.join(it)):
+ for ent_mode_, ent_name, ent_oid in tree_iter(b''.join(it)):
yield from _join(*get_oidx(repo, hexlify(ent_oid)), path + [ent_name])
elif typ == b'commit':
treeline = b''.join(it).split(b'\n', maxsplit=1)[0]
diff --git a/test/int/test_commit.py b/test/int/test_commit.py
index 2cd7c13f..bcc34883 100644
--- a/test/int/test_commit.py
+++ b/test/int/test_commit.py
@@ -61,6 +61,7 @@ def test_commit_parsing(tmpdir):
if coffs[-5] == b'-'[0]:
coff = - coff
commit_items = git.get_commit_items(commit, git.cp())
+ assert parents == b''
WVPASSEQ(commit_items.parents, [])
WVPASSEQ(commit_items.tree, tree)
WVPASSEQ(commit_items.author_name, b'Someone')
diff --git a/test/int/test_hashsplit.py b/test/int/test_hashsplit.py
index 12d0a1a3..2f8cf158 100644
--- a/test/int/test_hashsplit.py
+++ b/test/int/test_hashsplit.py
@@ -101,13 +101,12 @@ def test_fanout_behaviour():
def test_hashsplit_files(tmpdir):
# See HashSplitter_init for source of sizes
- blob_size = 1 << BUP_BLOBBITS
max_blob_size = 1 << (BUP_BLOBBITS + 2)
null_path = os.path.join(tmpdir, b'nulls')
blobs_in_file = 10
max_blob = bytearray(max_blob_size)
with open(null_path, 'wb') as f:
- for idx in range(blobs_in_file):
+ for _ in range(blobs_in_file):
f.write(max_blob)
max_blob = None
@@ -252,6 +251,5 @@ def test_hashsplitter_short_read():
return b''
hs = HashSplitter([DataObj()], bits=13)
count = 0
- for blob, lvl in hs:
- count += 1
+ for _ in hs: count += 1
assert count == 1
diff --git a/test/int/test_midx.py b/test/int/test_midx.py
index a8f55916..72ffca9a 100644
--- a/test/int/test_midx.py
+++ b/test/int/test_midx.py
@@ -19,7 +19,6 @@ def bupc(*args, **kwargs):
def test_missing_midx(tmpdir):
bup_dir = tmpdir + b'/bup'
- pack_dir = bup_dir + b'/objects/pack'
environb[b'GIT_DIR'] = bup_dir
environb[b'BUP_DIR'] = bup_dir
bupc(('init',))
@@ -30,7 +29,6 @@ def test_missing_midx(tmpdir):
bupc(('midx', '-f'))
midxs = glob(bup_dir + b'/objects/pack/*.midx')
assert len(midxs) == 1
- midx = midxs[0]
bupc(('midx', '--check', '-a'))
idxs = glob(bup_dir + b'/objects/pack/*.idx')
assert len(idxs) > 1
diff --git a/test/int/test_resolve.py b/test/int/test_resolve.py
index 08e3d648..abbd4075 100644
--- a/test/int/test_resolve.py
+++ b/test/int/test_resolve.py
@@ -75,7 +75,7 @@ def _test_resolve(repo, tmpdir):
res = resolve(b'/')
wvpasseq(1, len(res))
wvpasseq(((b'', vfs._root),), res)
- ignore, root_item = res[0]
+ _, root_item = res[0]
root_content = frozenset(vfs.contents(repo, root_item))
wvpasseq(frozenset([(b'.', root_item),
(b'.tag', vfs._tags),
@@ -101,7 +101,7 @@ def _test_resolve(repo, tmpdir):
wvpasseq(2, len(res))
wvpasseq(((b'', vfs._root), (b'.tag', vfs._tags)),
res)
- ignore, tag_item = res[1]
+ _, tag_item = res[1]
tag_content = frozenset(vfs.contents(repo, tag_item))
wvpasseq(frozenset([(b'.', tag_item),
(b'test-tag', expected_test_tag_item)]),
@@ -111,7 +111,7 @@ def _test_resolve(repo, tmpdir):
res = resolve(b'/test')
wvpasseq(2, len(res))
wvpasseq(((b'', vfs._root), (b'test', test_revlist_w_meta)), res)
- ignore, test_item = res[1]
+ _, test_item = res[1]
test_content = frozenset(vfs.contents(repo, test_item))
# latest has metadata here due to caching
wvpasseq(frozenset([(b'.', test_revlist_w_meta),
@@ -129,7 +129,7 @@ def _test_resolve(repo, tmpdir):
(b'test', test_revlist_w_meta),
(save_time_str, expected_latest_item_w_meta))
wvpasseq(expected, res)
- ignore, latest_item = res[2]
+ _, latest_item = res[2]
latest_content = frozenset(vfs.contents(repo, latest_item))
expected = frozenset((
x.name, vfs.Item(oid=x.oid, meta=x.meta))
for x in (tip_tree[name]
@@ -259,8 +259,8 @@ def _test_resolve(repo, tmpdir):
(b'dir', expected_dir_item))
def lresolve(*args, **keys):
return resolve(*args, **dict(keys, follow=False))
- for resname, resolver in (('resolve', resolve),
- ('resolve nofollow', lresolve)):
+ for resname_, resolver in (('resolve', resolve),
+ ('resolve nofollow', lresolve)):
for path in (b'/test/latest/dir-symlink/',
b'/test/latest/dir-symlink/.'):
vfs.clear_cache()
diff --git a/test/int/test_vfs.py b/test/int/test_vfs.py
index 673b3473..df6cb337 100644
--- a/test/int/test_vfs.py
+++ b/test/int/test_vfs.py
@@ -4,9 +4,8 @@ from os import symlink
from random import Random, randint
from stat import S_IFDIR, S_IFLNK, S_IFREG, S_ISDIR, S_ISREG
from sys import stderr
-import os
-import sys
from time import localtime, strftime, tzset
+import os, sys
import pytest
@@ -171,6 +170,7 @@ def test_misc(tmpdir):
with LocalRepo() as repo:
ls_tree = exo((b'git', b'ls-tree', b'test', b'symlink')).out
mode, typ, oidx, name = ls_tree.strip().split(None, 3)
+ assert typ == b'blob'
assert name == b'symlink'
link_item = vfs.Item(oid=unhexlify(oidx), meta=int(mode, 8))
wvpasseq(b'file', vfs.readlink(repo, link_item))
@@ -351,9 +351,8 @@ def test_duplicate_save_dates(tmpdir):
ex((b'env',))
ex((bup_path, b'init'))
ex((bup_path, b'index', b'-v', data_path))
- for i in range(11):
- ex((bup_path, b'save', b'-d', b'100000', b'-n', b'test',
- data_path))
+ for _ in range(11):
+ ex((bup_path, b'save', b'-d', b'100000', b'-n', b'test', data_path))
with LocalRepo() as repo:
res = vfs.resolve(repo, b'/test')
wvpasseq(2, len(res))
--
2.47.3