[PATCH 14/14] Accommodate and enable pylint use-dict-literal

0 views
Skip to first unread message

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/cmd/web.py | 20 +++++++++-----------
lib/bup/main.py | 24 ++++++++++++------------
3 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 4c40adc5..fa47d348 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -26,5 +26,6 @@ enable=
unnecessary-semicolon,
unused-import,
unused-wildcard-import,
+ use-dict-literal,
use-list-literal,
useless-return
diff --git a/lib/bup/cmd/web.py b/lib/bup/cmd/web.py
index 7807a558..80c70af7 100644
--- a/lib/bup/cmd/web.py
+++ b/lib/bup/cmd/web.py
@@ -190,10 +190,10 @@ class BupRequestHandler(tornado.web.RequestHandler):
human_param = ParamInfo(default=1 if human else 0,
from_req=from_req_bool,
normalize=normalize_bool)
- self.bup_param_info = dict(hash=default_false_param,
- hidden=default_false_param,
- human=human_param,
- meta=default_false_param)
+ self.bup_param_info = {'hash': default_false_param,
+ 'hidden': default_false_param,
+ 'human': human_param,
+ 'meta': default_false_param}

def decode_argument(self, value, name=None):
if name == 'path':
@@ -383,11 +383,9 @@ def main(argv):

git.check_repo_or_die()

- settings = dict(
- debug = 1,
- template_path = resource_path(b'web').decode('utf-8'),
- static_path = resource_path(b'web/static').decode('utf-8'),
- )
+ settings = {'debug': 1,
+ 'template_path': resource_path(b'web').decode('utf-8'),
+ 'static_path': resource_path(b'web/static').decode('utf-8')}

# Disable buffering on stdout, for debug messages
try:
@@ -396,8 +394,8 @@ def main(argv):
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

with LocalRepo() as repo:
- handlers = [ (r"(?P<path>/.*)", BupRequestHandler,
- dict(repo=repo, human=opt.human_readable))]
+ handlers = [(r"(?P<path>/.*)", BupRequestHandler,
+ {'repo': repo, 'human': opt.human_readable})]
application = tornado.web.Application(handlers, **settings)

http_server = HTTPServer(application)
diff --git a/lib/bup/main.py b/lib/bup/main.py
index fa2262c2..a8b7f18d 100755
--- a/lib/bup/main.py
+++ b/lib/bup/main.py
@@ -49,18 +49,18 @@ cmdpath = path.cmddir()
def usage(file=sys.stdout):
print('Usage: bup [-?|-h|--help] [-d BUP_DIR] [--debug] [--profile] '
'<command> [options...]\n', file=file)
- common = dict(
- ftp = 'Browse backup sets using an ftp-like client',
- fsck = 'Check backup sets for damage and add redundancy information',
- fuse = 'Mount your backup sets as a filesystem',
- help = 'Print detailed help for the given command',
- index = 'Create or display the index of files to back up',
- on = 'Backup a remote machine to the local one',
- restore = 'Extract files from a backup set',
- save = 'Save files into a backup set (note: run "bup index" first)',
- tag = 'Tag commits for easier access',
- web = 'Launch a web server to examine backup sets',
- )
+ common = {
+ 'ftp': 'Browse backup sets using an ftp-like client',
+ 'fsck': 'Check backup sets for damage and add redundancy information',
+ 'fuse': 'Mount your backup sets as a filesystem',
+ 'help': 'Print detailed help for the given command',
+ 'index': 'Create or display the index of files to back up',
+ 'on': 'Backup a remote machine to the local one',
+ 'restore': 'Extract files from a backup set',
+ 'save': 'Save files into a backup set (note: run "bup index" first)',
+ 'tag': 'Tag commits for easier access',
+ 'web': 'Launch a web server to examine backup sets',
+ }

print('Common commands:\n', file=file)
for cmd,synopsis in sorted(common.items()):
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Pushed to main.

--
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
test/int/test_hashsplit.py | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 86c2a3fc..185f4ad3 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -17,6 +17,7 @@ enable=
trailing-whitespace,
undefined-variable,
unidiomatic-typecheck,
+ unnecessary-comprehension,
unnecessary-lambda,
unnecessary-lambda-assignment,
unnecessary-pass,
diff --git a/test/int/test_hashsplit.py b/test/int/test_hashsplit.py
index b5639422..ba54b08d 100644
--- a/test/int/test_hashsplit.py
+++ b/test/int/test_hashsplit.py
@@ -228,11 +228,11 @@ def test_hashsplitter_object():
data = data[1:]
yield fed, 13
data = b''.join([b'%d\n' % x for x in range(10000)])
- WVPASSEQ([x for x in _splitbuf(data)],
- [x for x in _splitbufRHS(data)])
+ WVPASSEQ(list(_splitbuf(data)),
+ list(x for x in _splitbufRHS(data)))
data = b''.join([b'%.10x\n' % x for x in range(10000)])
- WVPASSEQ([x for x in _splitbuf(data)],
- [x for x in _splitbufRHS(data)])
+ WVPASSEQ(list(_splitbuf(data)),
+ list(_splitbufRHS(data)))

def test_hashsplitter_short_read():
class DataObj:
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/git.py | 3 +--
lib/bup/metadata.py | 3 +--
lib/bup/tree.py | 4 ++--
lib/bup/vfs.py | 4 ++--
test/int/test_metadata.py | 4 ++--
6 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index d757f7f6..4c40adc5 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -8,6 +8,7 @@ enable=
bad-classmethod-argument,
catching-non-exception,
consider-using-dict-items,
+ consider-using-enumerate,
consider-using-generator,
consider-using-in,
consider-using-max-builtin,
diff --git a/lib/bup/git.py b/lib/bup/git.py
index 86198268..26b2c172 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -581,8 +581,7 @@ class PackIdxList:
else:
_total_searches -= 1 # was counted by bloom
return None
- for i in range(len(self.packs)):
- p = self.packs[i]
+ for i, p in enumerate(self.packs):
if want_offset and isinstance(p, midx.PackMidx):
get_src = True
get_ofs = False
diff --git a/lib/bup/metadata.py b/lib/bup/metadata.py
index c6b8d83d..00144614 100644
--- a/lib/bup/metadata.py
+++ b/lib/bup/metadata.py
@@ -584,8 +584,7 @@ class Metadata:
# field name (including the user and group names) contains a
# newline or comma. If any field name does, then the results
# may be wrong. (Debian, at least, disallows them.)
- for i in range(len(acls)):
- acl = acls[i]
+ for i, acl in enumerate(acls):
if b',' in acl:
if path:
msg = 'error: unexpected comma in ACL entry;' \
diff --git a/lib/bup/tree.py b/lib/bup/tree.py
index 6e444f43..0d9d8111 100644
--- a/lib/bup/tree.py
+++ b/lib/bup/tree.py
@@ -72,8 +72,8 @@ def _abbreviate_tree_names(names):
for name in names:
out = name
level = abbrev
- for n in range(len(name)):
- level = level[name[n]]
+ for c in name:
+ level = level[c]
while True:
# backtrack a level
level = level[None]
diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py
index f901907a..bbed15d7 100644
--- a/lib/bup/vfs.py
+++ b/lib/bup/vfs.py
@@ -177,8 +177,8 @@ def _normal_or_chunked_file_size(repo, oid):

def _skip_chunks_before_offset(tree_data, offset):
entries = tree_entries(tree_data)
- for i in range(len(entries)):
- ent_ofs = int(entries[i][1], 16)
+ for i, entry in enumerate(entries):
+ ent_ofs = int(entry[1], 16)
if ent_ofs > offset:
return entries[i - 1:]
if ent_ofs == offset:
diff --git a/test/int/test_metadata.py b/test/int/test_metadata.py
index 8dec9893..4cc6ac53 100644
--- a/test/int/test_metadata.py
+++ b/test/int/test_metadata.py
@@ -214,8 +214,8 @@ def test_apply_to_path_restricted_access(tmpdir):
if metadata.xattr and m.linux_xattr:
expected_errors.append('error: xattr.set ')
WVPASS(len(helpers.saved_errors) == len(expected_errors))
- for i in range(len(expected_errors)):
- assert str(helpers.saved_errors[i]).startswith(expected_errors[i])
+ for i, err in enumerate(expected_errors):
+ assert str(helpers.saved_errors[i]).startswith(err)
finally:
clear_errors()

--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
test/int/test_hashsplit.py | 10 ++++------
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index e7f103f2..86c2a3fc 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -7,6 +7,7 @@ enable=
assignment-from-no-return,
bad-classmethod-argument,
catching-non-exception,
+ consider-using-dict-items,
consider-using-in,
consider-using-max-builtin,
inconsistent-return-statements,
diff --git a/test/int/test_hashsplit.py b/test/int/test_hashsplit.py
index a3872f88..b5639422 100644
--- a/test/int/test_hashsplit.py
+++ b/test/int/test_hashsplit.py
@@ -34,12 +34,12 @@ split_test_objs = {
}

def test_samples():
- for k in split_test_objs:
+ for k, obj in split_test_objs.items():

# Verify that the k least significant bits are 1 and that
# the next most significant bit is zero (i.e. that the
# rollsum of the data matched what we expect for this k).
- rsum = _helpers.rollsum(split_test_objs[k])
+ rsum = _helpers.rollsum(obj)
ones = (1 << k) - 1
mask = (ones << 1) | 1
WVPASSEQ(rsum & mask, ones)
@@ -55,11 +55,9 @@ def test_samples():
# (quirk in the original algorithm -- see ./DESIGN).
if exp_level > 0:
exp_level -= 1
- hs = HashSplitter([BytesIO(split_test_objs[k])],
- bits=BUP_BLOBBITS,
- fanbits=1)
+ hs = HashSplitter([BytesIO(obj)], bits=BUP_BLOBBITS, fanbits=1)
blob, level = next(hs)
- WVPASSEQ(blob, split_test_objs[k])
+ WVPASSEQ(blob, obj)
WVPASSEQ(level, exp_level)

def test_rolling_sums():
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
test/int/test_git.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/.pylintrc b/.pylintrc
index dbc5472b..3ecd7988 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -4,6 +4,7 @@
[MESSAGES CONTROL]
disable=all
enable=
+ assignment-from-no-return,
bad-classmethod-argument,
catching-non-exception,
consider-using-in,
diff --git a/test/int/test_git.py b/test/int/test_git.py
index cf10e8fe..20a4367b 100644
--- a/test/int/test_git.py
+++ b/test/int/test_git.py
@@ -200,7 +200,7 @@ def test_long_index(tmpdir):
idx.add(obj2_bin, 2, 0xffffffffff)
idx.add(obj3_bin, 3, 0xff)
name = tmpdir + b'/tmp.idx'
- r = idx.write(name, pack_bin)
+ idx.write(name, pack_bin)
with git.PackIdxV2(name, open(name, 'rb')) as i:
WVPASSEQ(i.find_offset(obj_bin), 0xfffffffff)
WVPASSEQ(i.find_offset(obj2_bin), 0xffffffffff)
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/gc.py | 2 +-
lib/bup/helpers.py | 2 +-
test/int/test_vfs.py | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 9c19784e..0be3df57 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -14,6 +14,7 @@ enable=
undefined-variable,
unidiomatic-typecheck,
unnecessary-lambda,
+ unnecessary-lambda-assignment,
unnecessary-semicolon,
unused-import,
unused-wildcard-import,
diff --git a/lib/bup/gc.py b/lib/bup/gc.py
index 8d24afff..d6265007 100644
--- a/lib/bup/gc.py
+++ b/lib/bup/gc.py
@@ -96,7 +96,7 @@ def find_live_objects(existing_count, cat_pipe, refs=None, *,
# live_blobs will hold on to the fd until close or exit
os.unlink(bloom_filename)
live_trees = set()
- stop_at = lambda x: unhexlify(x) in live_trees
+ def stop_at(x): return unhexlify(x) in live_trees
oid_exists = idx_list.exists if idx_list else None
approx_live_count = 0
scan_refs = refs if refs else list(git.list_refs())
diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index 2e7aa894..8b0f2670 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -220,7 +220,7 @@ class MergeIterItem:

def merge_iter(iters, pfreq, pfunc, pfinal, key=None):
if key:
- samekey = lambda e, pe: getattr(e, key) == getattr(pe, key, None)
+ def samekey(e, pe): return getattr(e, key) == getattr(pe, key, None)
else:
samekey = operator.eq
count = 0
diff --git a/test/int/test_vfs.py b/test/int/test_vfs.py
index 68bcdb8f..248f5502 100644
--- a/test/int/test_vfs.py
+++ b/test/int/test_vfs.py
@@ -138,7 +138,7 @@ def test_item_mode():
wvpasseq(meta.mode, vfs.item_mode(vfs.Item(oid=oid, meta=meta)))

def test_reverse_suffix_duplicates():
- suffix = lambda x: tuple(vfs._reverse_suffix_duplicates(x))
+ def suffix(x): return tuple(vfs._reverse_suffix_duplicates(x))
wvpasseq((b'x',), suffix((b'x',)))
wvpasseq((b'x', b'y'), suffix((b'x', b'y')))
wvpasseq((b'x-1', b'x-0'), suffix((b'x',) * 2))
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/git.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/.pylintrc b/.pylintrc
index 5e5f23fa..dbc5472b 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -20,4 +20,5 @@ enable=
unnecessary-semicolon,
unused-import,
unused-wildcard-import,
+ use-list-literal,
useless-return
diff --git a/lib/bup/git.py b/lib/bup/git.py
index a67d31b4..86198268 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -995,7 +995,7 @@ class PackWriter:

class PackIdxV2Writer:
def __init__(self):
- self.idx = list(list() for i in range(256))
+ self.idx = [[] for i in range(256)]
self.count = 0

def add(self, sha, crc, offs):
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/vfs.py | 4 +---
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 0be3df57..a99bca71 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -6,6 +6,7 @@ disable=all
enable=
catching-non-exception,
consider-using-in,
+ consider-using-max-builtin,
inconsistent-return-statements,
return-in-init,
super-init-not-called,
diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py
index 0d63fe8b..f901907a 100644
--- a/lib/bup/vfs.py
+++ b/lib/bup/vfs.py
@@ -190,9 +190,7 @@ def _tree_chunks(repo, tree_data, startofs):
# name is the chunk's hex offset in the original file
for mode, name, oid in _skip_chunks_before_offset(tree_data, startofs):
ofs = int(name, 16)
- skipmore = startofs - ofs
- if skipmore < 0:
- skipmore = 0
+ skipmore = max(0, startofs - ofs)
_, obj_t, _, it = get_oidx(repo, hexlify(oid))
data = b''.join(it)
if S_ISDIR(mode):
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/repo/local.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/.pylintrc b/.pylintrc
index a99bca71..5e5f23fa 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -4,6 +4,7 @@
[MESSAGES CONTROL]
disable=all
enable=
+ bad-classmethod-argument,
catching-non-exception,
consider-using-in,
consider-using-max-builtin,
diff --git a/lib/bup/repo/local.py b/lib/bup/repo/local.py
index 35fc732a..5f612d02 100644
--- a/lib/bup/repo/local.py
+++ b/lib/bup/repo/local.py
@@ -70,7 +70,7 @@ class LocalRepo(RepoProtocol):
def is_remote(self): return False

@classmethod
- def create(self, repo_dir=None):
+ def create(cls, repo_dir=None):
# FIXME: this is not ideal, we should somehow
# be able to call the constructor instead?
git.init_repo(repo_dir)
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/cmd/meta.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 185f4ad3..d757f7f6 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -8,6 +8,7 @@ enable=
bad-classmethod-argument,
catching-non-exception,
consider-using-dict-items,
+ consider-using-generator,
consider-using-in,
consider-using-max-builtin,
inconsistent-return-statements,
diff --git a/lib/bup/cmd/meta.py b/lib/bup/cmd/meta.py
index 4b6f1bb4..34dfcf14 100644
--- a/lib/bup/cmd/meta.py
+++ b/lib/bup/cmd/meta.py
@@ -67,9 +67,9 @@ def main(argv):
metadata.verbose = opt.verbose - opt.quiet
opt.file = argv_bytes(opt.file) if opt.file else None

- action_count = sum([bool(x) for x in [opt.create, opt.list, opt.extract,
+ action_count = sum(bool(x) for x in [opt.create, opt.list, opt.extract,
opt.start_extract, opt.finish_extract,
- opt.edit]])
+ opt.edit])
if action_count > 1:
o.fatal("bup: only one action permitted: --create --list --extract --edit")
if action_count == 0:
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:50 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 7 ++++---
lib/bup/cmd/restore.py | 2 +-
lib/bup/git.py | 2 +-
lib/bup/tree.py | 2 +-
lib/bup/xstat.py | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index caae1e82..c6d67408 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -4,15 +4,16 @@
[MESSAGES CONTROL]
disable=all
enable=
- syntax-error,
catching-non-exception,
consider-using-in,
inconsistent-return-statements,
return-in-init,
+ super-init-not-called,
+ syntax-error,
trailing-whitespace,
undefined-variable,
unidiomatic-typecheck,
+ unnecessary-semicolon,
unused-import,
unused-wildcard-import,
- useless-return,
- super-init-not-called
+ useless-return
diff --git a/lib/bup/cmd/restore.py b/lib/bup/cmd/restore.py
index e0ff629b..6be39f8e 100644
--- a/lib/bup/cmd/restore.py
+++ b/lib/bup/cmd/restore.py
@@ -143,7 +143,7 @@ def write_file_content_sparsely(repo, dest_path, vfs_file):
with vfs.fopen(repo, vfs_file) as inf:
outfd = os.open(dest_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
try:
- trailing_zeros = 0;
+ trailing_zeros = 0
for b in chunkyreader(inf):
trailing_zeros = write_sparsely(outfd, b, 512, trailing_zeros)
pos = os.lseek(outfd, trailing_zeros, os.SEEK_END)
diff --git a/lib/bup/git.py b/lib/bup/git.py
index d5665436..f4d83fd5 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -1347,7 +1347,7 @@ class CatPipe:
stderr=subprocess.DEVNULL,
close_fds=True,
env=_gitenv(self.repo_dir))
- tmp.wait();
+ tmp.wait()
self.have_batch_command = tmp.returncode == 0

def close(self, wait=False):
diff --git a/lib/bup/tree.py b/lib/bup/tree.py
index 58369ab4..6e444f43 100644
--- a/lib/bup/tree.py
+++ b/lib/bup/tree.py
@@ -84,7 +84,7 @@ def _abbreviate_tree_names(names):
candidate = out[:-1]
# of course we must not have an invalid name
if candidate in (b'', b'.', b'..'):
- break;
+ break
out = candidate
outnames.append(out)
return outnames
diff --git a/lib/bup/xstat.py b/lib/bup/xstat.py
index 382a7b76..5fbc4a10 100644
--- a/lib/bup/xstat.py
+++ b/lib/bup/xstat.py
@@ -26,7 +26,7 @@ def nsecs_to_timeval(ns):

def fstime_floor_secs(ns):
"""Return largest integer not greater than ns / 10e8."""
- return int(ns) // 10**9;
+ return int(ns) // 10**9


def fstime_to_timespec(ns):
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:51 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
test/int/test_metadata.py | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 3ecd7988..e7f103f2 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -18,6 +18,7 @@ enable=
unidiomatic-typecheck,
unnecessary-lambda,
unnecessary-lambda-assignment,
+ unnecessary-pass,
unnecessary-semicolon,
unused-import,
unused-wildcard-import,
diff --git a/test/int/test_metadata.py b/test/int/test_metadata.py
index 3c7a28fa..8dec9893 100644
--- a/test/int/test_metadata.py
+++ b/test/int/test_metadata.py
@@ -201,9 +201,8 @@ def test_apply_to_path_restricted_access(tmpdir):
try:
metadata.xattr.set(path, b'user.buptest', b'bup')
except:
- print("failed to set test xattr")
# ignore any failures here - maybe FS cannot do it
- pass
+ print("failed to set test xattr")
m = metadata.from_path(path, archive_path=path, save_symlinks=True)
WVPASSEQ(m.path, path)
os.chmod(parent, 0o000)
--
2.47.3

Rob Browning

unread,
Mar 2, 2026, 6:53:51 PM (2 days ago) Mar 2
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/drecurse.py | 2 +-
lib/bup/gc.py | 2 +-
lib/bup/git.py | 4 ++--
lib/bup/helpers.py | 2 +-
test/int/test_resolve.py | 3 +--
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index c6d67408..9c19784e 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -13,6 +13,7 @@ enable=
trailing-whitespace,
undefined-variable,
unidiomatic-typecheck,
+ unnecessary-lambda,
unnecessary-semicolon,
unused-import,
unused-wildcard-import,
diff --git a/lib/bup/drecurse.py b/lib/bup/drecurse.py
index 90d81eed..8348c681 100644
--- a/lib/bup/drecurse.py
+++ b/lib/bup/drecurse.py
@@ -26,7 +26,7 @@ except AttributeError:

def finalized_fd(path):
fd = os.open(path, os.O_RDONLY|O_LARGEFILE|O_NOFOLLOW|os.O_NDELAY)
- return finalized(fd, lambda x: os.close(x))
+ return finalized(fd, os.close)


def _dirlist():
diff --git a/lib/bup/gc.py b/lib/bup/gc.py
index ce76438c..8d24afff 100644
--- a/lib/bup/gc.py
+++ b/lib/bup/gc.py
@@ -97,7 +97,7 @@ def find_live_objects(existing_count, cat_pipe, refs=None, *,
os.unlink(bloom_filename)
live_trees = set()
stop_at = lambda x: unhexlify(x) in live_trees
- oid_exists = (lambda oid: idx_list.exists(oid)) if idx_list else None
+ oid_exists = idx_list.exists if idx_list else None
approx_live_count = 0
scan_refs = refs if refs else list(git.list_refs())
ref_n = len(scan_refs)
diff --git a/lib/bup/git.py b/lib/bup/git.py
index f4d83fd5..a67d31b4 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -705,7 +705,7 @@ class PackIdxList:
if not p in new_packs:
p.close()
new_packs = list(new_packs)
- new_packs.sort(reverse=True, key=lambda x: len(x))
+ new_packs.sort(reverse=True, key=len)
self.packs = new_packs
if self.bloom is None and os.path.exists(bfull):
self.bloom = bloom.ShaBloom(bfull)
@@ -811,7 +811,7 @@ class LocalPackStore():
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),
- lambda x: os.close(x)))
+ os.close))
self._file.write(b'PACK\0\0\0\2\0\0\0\0')
self._idx = PackIdxV2Writer()
err_stack.pop_all()
diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index 69896b4e..2e7aa894 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -86,7 +86,7 @@ def temp_dir(*args, **kwargs):
# gc'ed, even if you pop_all() (the new stack will also trigger
# the deletion) because
# https://github.com/python/cpython/issues/88458
- return finalized(mkdtemp(*args, **kwargs), lambda x: rmtree(x))
+ return finalized(mkdtemp(*args, **kwargs), rmtree)


def open_in(fd, path, *args, **kwargs):
diff --git a/test/int/test_resolve.py b/test/int/test_resolve.py
index 7908755a..e65500fc 100644
--- a/test/int/test_resolve.py
+++ b/test/int/test_resolve.py
@@ -298,8 +298,7 @@ def _test_resolve_loop(repo, tmpdir):
[name for name, item in res_ex.terminus])

def test_local_resolve_loop(tmpdir):
- prep_and_test_repo(tmpdir,
- lambda x: LocalRepo(x), _test_resolve_loop)
+ prep_and_test_repo(tmpdir, LocalRepo, _test_resolve_loop)

def test_remote_resolve_loop(tmpdir):
prep_and_test_repo(tmpdir,
--
2.47.3

Reply all
Reply to author
Forward
0 new messages