[PATCH 10/10] pylint: enable inconsistent-return-statements

0 views
Skip to first unread message

Rob Browning

unread,
Sep 17, 2021, 1:15:40 PM9/17/21
to bup-...@googlegroups.com, Johannes Berg
From: Johannes Berg <joha...@sipsolutions.net>

Signed-off-by: Johannes Berg <joha...@sipsolutions.net>
Reviewed-by: Rob Browning <r...@defaultvalue.org>
[r...@defaultvalue.org: return early for dry run in import_duplicity exo]
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
.pylintrc | 1 +
lib/bup/client.py | 3 +++
lib/bup/cmd/ftp.py | 3 ++-
lib/bup/cmd/fuse.py | 1 +
lib/bup/cmd/get.py | 2 ++
lib/bup/cmd/import_duplicity.py | 7 ++++---
lib/bup/cmd/midx.py | 2 +-
lib/bup/cmd/restore.py | 1 +
lib/bup/cmd/save.py | 1 +
lib/bup/cmd/web.py | 1 +
lib/bup/git.py | 4 ++--
lib/bup/helpers.py | 4 +++-
lib/bup/vfs.py | 1 +
test/int/test_index.py | 1 +
14 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 0f7c2ed7..f9e3dfb3 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -5,6 +5,7 @@ disable=all
enable=
catching-non-exception,
consider-using-in,
+ inconsistent-return-statements,
return-in-init,
trailing-whitespace,
undefined-variable,
diff --git a/lib/bup/client.py b/lib/bup/client.py
index 6eeb7081..25320545 100644
--- a/lib/bup/client.py
+++ b/lib/bup/client.py
@@ -158,6 +158,8 @@ class Client:
return self.conn.check_ok()
except Exception as e:
reraise(ClientError(e))
+ # reraise doesn't return
+ return None

def check_busy(self):
if self._busy:
@@ -515,6 +517,7 @@ class PackWriter_Remote(git.PackWriter):
self.onclose() # Unbusy
self.objcache = None
return self.suggest_packs() # Returns last idx received
+ return None

def close(self):
id = self._end()
diff --git a/lib/bup/cmd/ftp.py b/lib/bup/cmd/ftp.py
index 4694dd95..99121f0d 100755
--- a/lib/bup/cmd/ftp.py
+++ b/lib/bup/cmd/ftp.py
@@ -26,7 +26,7 @@ def do_ls(repo, pwd, args, out):
opt = ls.opts_from_cmdline(args, onabort=OptionError, pwd=pwd_str)
except OptionError as e:
log('error: %s' % e)
- return
+ return None
return ls.within_repo(repo, opt, out, pwd_str)


@@ -90,6 +90,7 @@ def enter_completion(text, iteration):
except Exception as e2:
log('Error printing traceback: %s\n' % e2)
log('\nError in completion: %s\n' % e)
+ return None


optspec = """
diff --git a/lib/bup/cmd/fuse.py b/lib/bup/cmd/fuse.py
index b1be8ac0..385bea9f 100755
--- a/lib/bup/cmd/fuse.py
+++ b/lib/bup/cmd/fuse.py
@@ -106,6 +106,7 @@ class BupFs(fuse.Fuse):
# Return None since read doesn't need the file atm...
# If we *do* return the file, it'll show up as the last argument
#return vfs.fopen(repo, item)
+ return None

def read(self, path, size, offset):
path = argv_bytes(path)
diff --git a/lib/bup/cmd/get.py b/lib/bup/cmd/get.py
index 8629f4fd..599dcc6b 100755
--- a/lib/bup/cmd/get.py
+++ b/lib/bup/cmd/get.py
@@ -370,6 +370,8 @@ def handle_ff(item, src_repo, writer, opt):
return item.src.hash, unhexlify(commit_items.tree)
misuse('destination is not an ancestor of source for %s'
% spec_msg(item.spec))
+ # misuse() doesn't return
+ return None


def resolve_append(spec, src_repo, dest_repo):
diff --git a/lib/bup/cmd/import_duplicity.py b/lib/bup/cmd/import_duplicity.py
index 78ed1ee2..3e3cce74 100755
--- a/lib/bup/cmd/import_duplicity.py
+++ b/lib/bup/cmd/import_duplicity.py
@@ -31,9 +31,10 @@ def exc(cmd, shell=False):

def exo(cmd, shell=False, preexec_fn=None, close_fds=True):
logcmd(cmd)
- if not dry_run:
- return helpers.exo(cmd, shell=shell, preexec_fn=preexec_fn,
- close_fds=close_fds)[0]
+ if dry_run:
+ return b''
+ return helpers.exo(cmd, shell=shell, preexec_fn=preexec_fn,
+ close_fds=close_fds)[0]

def redirect_dup_output():
os.dup2(1, 3)
diff --git a/lib/bup/cmd/midx.py b/lib/bup/cmd/midx.py
index 983ba334..604f7e3b 100755
--- a/lib/bup/cmd/midx.py
+++ b/lib/bup/cmd/midx.py
@@ -116,7 +116,7 @@ def _do_midx(outdir, outfilename, infilenames, prefixstr,
or ((auto or force) and len(infilenames) < 2) \
or (force and not total):
debug1('midx: nothing to do.\n')
- return
+ return None

pages = int(total/SHA_PER_PAGE) or 1
bits = int(math.ceil(math.log(pages, 2)))
diff --git a/lib/bup/cmd/restore.py b/lib/bup/cmd/restore.py
index aeb1c7ba..ee403b6c 100755
--- a/lib/bup/cmd/restore.py
+++ b/lib/bup/cmd/restore.py
@@ -44,6 +44,7 @@ def valid_restore_path(path):
path = path[1:]
if b'/' in path:
return True
+ return False

def parse_owner_mappings(type, options, fatal):
"""Traverse the options and parse all --map-TYPEs, or call Option.fatal()."""
diff --git a/lib/bup/cmd/save.py b/lib/bup/cmd/save.py
index 70c7159b..1325b4d9 100755
--- a/lib/bup/cmd/save.py
+++ b/lib/bup/cmd/save.py
@@ -269,6 +269,7 @@ def main(argv):
link_paths = hlink_db.node_paths(ent.dev, ent.ino)
if link_paths:
return link_paths[0]
+ return None

total = ftotal = 0
if opt.progress:
diff --git a/lib/bup/cmd/web.py b/lib/bup/cmd/web.py
index d83fb12f..7de8ed72 100755
--- a/lib/bup/cmd/web.py
+++ b/lib/bup/cmd/web.py
@@ -159,6 +159,7 @@ class BupRequestHandler(tornado.web.RequestHandler):
hidden_shown=show_hidden,
dir_contents=_dir_contents(self.repo, resolution,
show_hidden=show_hidden))
+ return None

@gen.coroutine
def _get_file(self, repo, path, resolved):
diff --git a/lib/bup/git.py b/lib/bup/git.py
index cccc44ef..ce8041a7 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -263,8 +263,7 @@ def demangle_name(name, mode):
elif name.endswith(b'.bupm'):
return (name[:-5],
BUP_CHUNKED if stat.S_ISDIR(mode) else BUP_NORMAL)
- else:
- return (name, BUP_NORMAL)
+ return (name, BUP_NORMAL)


def calc_hash(type, content):
@@ -1269,6 +1268,7 @@ class CatPipe:
if wait:
p.wait()
return p.returncode
+ return None

def restart(self):
self.close()
diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py
index e2f543f6..93fa9e16 100644
--- a/lib/bup/helpers.py
+++ b/lib/bup/helpers.py
@@ -273,6 +273,8 @@ def quote(x):
if isinstance(x, compat.str_type):
return squote(x)
assert False
+ # some versions of pylint get confused
+ return None

def shstr(cmd):
"""Return a shell quoted string for cmd if it's a sequence, else cmd.
@@ -908,7 +910,7 @@ def handle_ctrl_c():
if exctype == KeyboardInterrupt:
log('\nInterrupted.\n')
else:
- return oldhook(exctype, value, traceback)
+ oldhook(exctype, value, traceback)
sys.excepthook = newhook


diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py
index 09bb1d37..09267f4c 100644
--- a/lib/bup/vfs.py
+++ b/lib/bup/vfs.py
@@ -398,6 +398,7 @@ def is_valid_cache_key(x):
return True
if tag == b'res:':
return True
+ return False

def cache_get(key):
global _cache
diff --git a/test/int/test_index.py b/test/int/test_index.py
index d00260ea..f24b719a 100644
--- a/test/int/test_index.py
+++ b/test/int/test_index.py
@@ -60,6 +60,7 @@ def eget(l, ename):
for e in l:
if e.name == ename:
return e
+ return None

def test_index_negative_timestamps(tmpdir):
# Makes 'foo' exist
--
2.30.2

Reply all
Reply to author
Forward
0 new messages