]> arthur.barton.de Git - bup.git/commitdiff
pylint: add undefined-variable
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 27 Aug 2021 22:40:16 +0000 (00:40 +0200)
committerRob Browning <rlb@defaultvalue.org>
Fri, 17 Sep 2021 16:27:48 +0000 (11:27 -0500)
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: add missing %s in validate_vfs_path changes]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
.pylintrc
lib/bup/cmd/get.py
lib/bup/cmd/memtest.py
lib/bup/cmd/midx.py
lib/bup/cmd/server.py
lib/bup/cmd/xstat.py
lib/bup/compat.py

index 8a6e0fc35abfcdce84f3b051015c024993d640e3..997e09fd0f3b72a291168c3cc7f56cedaf9545f5 100644 (file)
--- a/.pylintrc
+++ b/.pylintrc
@@ -6,6 +6,7 @@ enable=
   consider-using-in,
   return-in-init,
   trailing-whitespace,
+  undefined-variable,
   unidiomatic-typecheck,
   unused-import,
   unused-wildcard-import,
index 2b8ea1ac858908244dd909c16fc831cfe87170bf..8629f4fd10c3f2693817c0472fb36c3c6a23eb10 100755 (executable)
@@ -15,7 +15,7 @@ from bup.compat import (
 )
 from bup.git import get_cat_data, parse_commit, walk_object
 from bup.helpers import add_error, debug1, log, saved_errors
-from bup.helpers import hostname, tty_width
+from bup.helpers import hostname, tty_width, parse_num
 from bup.io import path_msg
 from bup.pwdgrp import userfullname, username
 from bup.repo import LocalRepo, RemoteRepo
@@ -164,7 +164,7 @@ def parse_args(args):
             opt.compress = int(opt.compress)
         elif arg == b'--bwlimit':
             (opt.bwlimit,), remaining = require_n_args_or_die(1, remaining)
-            opt.bwlimit = long(opt.bwlimit)
+            opt.bwlimit = int(opt.bwlimit)
         elif arg.startswith(b'-') and len(arg) > 2 and arg[1] != b'-':
             # Try to interpret this as -xyz, i.e. "-xyz -> -x -y -z".
             # We do this last so that --foo -bar is valid if --foo
@@ -281,11 +281,11 @@ def cleanup_vfs_path(p):
     return b'/' + result
 
 
-def validate_vfs_path(p):
+def validate_vfs_path(p, spec):
     if p.startswith(b'/.') \
        and not p.startswith(b'/.tag/'):
         misuse('unsupported destination path %s in %s'
-               % (path_msg(dest.path), spec_msg(spec)))
+               % (path_msg(p), spec_msg(spec)))
     return p
 
 
@@ -419,7 +419,7 @@ def resolve_pick(spec, src_repo, dest_repo):
         misuse('no destination provided for %s', spec_args)
     dest = find_vfs_item(spec.dest, dest_repo)
     if not dest:
-        cp = validate_vfs_path(cleanup_vfs_path(spec.dest))
+        cp = validate_vfs_path(cleanup_vfs_path(spec.dest), spec)
         dest = default_loc._replace(path=cp)
     else:
         if not dest.type == 'branch' and not dest.path.startswith(b'/.tag/'):
@@ -481,7 +481,7 @@ def resolve_replace(spec, src_repo, dest_repo):
             misuse('%s impossible; can only overwrite branch or tag'
                   % spec_args)
     else:
-        cp = validate_vfs_path(cleanup_vfs_path(spec.dest))
+        cp = validate_vfs_path(cleanup_vfs_path(spec.dest), spec)
         dest = default_loc._replace(path=cp)
     if not dest.path.startswith(b'/.tag/') \
        and not src.type in ('branch', 'save', 'commit'):
index 831ec54b4e9c28fae6c3e14a2f0de903ec116d00..b2027c42d83c7db580576ded97cf746fc0425abc 100755 (executable)
@@ -5,6 +5,7 @@ import re, resource, sys, time
 from bup import git, bloom, midx, options, _helpers
 from bup.compat import range
 from bup.io import byte_stream
+from bup.helpers import log
 
 
 _linux_warned = 0
index ba13b4a030b61ba00a7c64bc578bef09212a05e3..983ba334db31a014cd13f67d39bc4819dddf3ac0 100755 (executable)
@@ -147,15 +147,15 @@ def _do_midx(outdir, outfilename, infilenames, prefixstr,
 
 
     # This is just for testing (if you enable this, don't clear inp above)
-    if 0:
-        p = midx.PackMidx(outfilename)
-        assert(len(p.idxnames) == len(infilenames))
-        log(repr(p.idxnames) + '\n')
-        assert(len(p) == total)
-        for pe, e in p, git.idxmerge(inp, final_progress=False):
-            pin = next(pi)
-            assert(i == pin)
-            assert(p.exists(i))
+    if 0:
+        p = midx.PackMidx(outfilename)
+        assert(len(p.idxnames) == len(infilenames))
+        log(repr(p.idxnames) + '\n')
+        assert(len(p) == total)
+        for pe, e in p, git.idxmerge(inp, final_progress=False):
+            pin = next(pi)
+            assert(i == pin)
+            assert(p.exists(i))
 
     return total, outfilename
 
index 824a9b2545cb1a88f602cf1301e05ead2edaff62..357442847e1872265393381e887fb2c9c64b08f6 100755 (executable)
@@ -228,7 +228,7 @@ def rev_list(conn, _):
     if rv:
         msg = 'git rev-list returned error %d' % rv
         conn.error(msg)
-        raise GitError(msg)
+        raise git.GitError(msg)
     conn.ok()
 
 def resolve(conn, args):
index 246af24f3a9b3031a5878f55cb3c5ba1de3fbc58..5255c37e1bad09a86ca62226c719a3e97d9b0a97 100755 (executable)
@@ -14,7 +14,7 @@ from bup.helpers import add_error, parse_timestamp, saved_errors, \
 from bup.io import byte_stream
 
 
-def parse_timestamp_arg(field, value):
+def parse_timestamp_arg(o, field, value):
     res = str(value) # Undo autoconversion.
     try:
         res = parse_timestamp(res)
@@ -50,9 +50,9 @@ def main(argv):
     o = options.Options(optspec)
     (opt, flags, remainder) = o.parse_bytes(argv[1:])
 
-    atime_resolution = parse_timestamp_arg('atime', opt.atime_resolution)
-    mtime_resolution = parse_timestamp_arg('mtime', opt.mtime_resolution)
-    ctime_resolution = parse_timestamp_arg('ctime', opt.ctime_resolution)
+    atime_resolution = parse_timestamp_arg(o, 'atime', opt.atime_resolution)
+    mtime_resolution = parse_timestamp_arg(o, 'mtime', opt.mtime_resolution)
+    ctime_resolution = parse_timestamp_arg(o, 'ctime', opt.ctime_resolution)
 
     treat_include_fields_as_definitive = True
     for flag, value in flags:
index c3225a5ccdf9bdea155e2f65c16b9587ad34b9f9..72722017addc5dd3cb52589576576b8a99a1b04b 100644 (file)
@@ -16,6 +16,8 @@ if py3:
     from os import environb as environ
     from os import fsdecode, fsencode
     from shlex import quote
+    # pylint: disable=undefined-variable
+    # (for python2 looking here)
     ModuleNotFoundError = ModuleNotFoundError
     input = input
     range = range
@@ -93,9 +95,14 @@ else:  # Python 2
     # pylint: disable=unused-import
     from bup.py2raise import reraise
 
+    # on py3 this causes errors, obviously
+    # pylint: disable=undefined-variable
     input = raw_input
+    # pylint: disable=undefined-variable
     range = xrange
+    # pylint: disable=undefined-variable
     str_type = basestring
+    # pylint: disable=undefined-variable
     int_types = (int, long)
 
     hexstr = hexlify