From 6fc27237f08bf60a2403d2edb45ef6c0b1d95399 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 20 Dec 2020 13:04:59 +0800 Subject: [PATCH] pybind/ceph_argparse.py: drop unused variable and other PEP8 compliance cleanups Signed-off-by: Kefu Chai --- src/pybind/ceph_argparse.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index ac985e5113e11..6e3a7b8e6dcdc 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -564,11 +564,11 @@ class CephFragment(CephArgtype): raise ArgumentFormat("{0} not a hex integer".format(val)) try: int(val) - except: + except ValueError: raise ArgumentFormat('can\'t convert {0} to integer'.format(val)) try: int(bits) - except: + except ValueError: raise ArgumentFormat('can\'t convert {0} to integer'.format(bits)) self.val = s @@ -1077,15 +1077,12 @@ def validate(args, signature, flags=0, partial=False): # Have an arg; validate it try: validate_one(myarg, desc) - valid = True except ArgumentError as e: - valid = False - # argument mismatch if not desc.req: # if not required, just push back; it might match # the next arg - save_exception = [ myarg, e ] + save_exception = [myarg, e] myargs.insert(0, myarg) break else: @@ -1171,9 +1168,9 @@ def validate_command(sigdict, args, verbose=False): # (relies on a cmdsig being key,val where val is a list of len 1) def grade(cmd): - # prefer optional arguments over required ones - sigs = cmd['sig'] - return sum(map(lambda sig: sig.req, sigs)) + # prefer optional arguments over required ones + sigs = cmd['sig'] + return sum(map(lambda sig: sig.req, sigs)) bestcmds_sorted = sorted(bestcmds, key=grade) if verbose: @@ -1227,7 +1224,6 @@ def validate_command(sigdict, args, verbose=False): return valid_dict - def find_cmd_target(childargs): """ Using a minimal validation, figure out whether the command @@ -1312,7 +1308,6 @@ class RadosThread(threading.Thread): def run_in_thread(func, *args, **kwargs): - interrupt = False timeout = kwargs.pop('timeout', 0) if timeout == 0 or timeout == None: # python threading module will just get blocked if timeout is `None`, -- 2.39.5