← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~powersj/cloud-init:pycodestyle into cloud-init:master

 

Joshua Powers has proposed merging ~powersj/cloud-init:pycodestyle into cloud-init:master.

Commit message:
pycodestyle cleanup


Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~powersj/cloud-init/+git/cloud-init/+merge/316042

This make master pass pycodestyle (2.3.1) cleanly, currently:

$ pycodestyle cloudinit/ tests/ tools/
tools/make-mime.py:25:5: E722 do not use bare except'
tools/mock-meta.py:252:17: E722 do not use bare except'


For tools/make-mime.py:25:5: E722 do not use bare except' the use case is when someone runs
    ./make-mime.py --attach commis
instead of
    ./make-mime.py --attach commissaire.txt:x-commissaire-host

The split can cause a ValueError potentially if there is no : 
     

For tools/mock-meta.py:262:17: E722 do not use bare except' the use case is a dictionary look up occurs potentially when an unknown key is given:
    key_name = key_ids[key_id]

Do note that version 2.3.0 falsely reported a dozen or so E302 and E306 errors.
-- 
Your team cloud init development team is requested to review the proposed merge of ~powersj/cloud-init:pycodestyle into cloud-init:master.
diff --git a/tools/make-mime.py b/tools/make-mime.py
index 1272712..f6a7204 100755
--- a/tools/make-mime.py
+++ b/tools/make-mime.py
@@ -22,7 +22,7 @@ def file_content_type(text):
     try:
         filename, content_type = text.split(":", 1)
         return (open(filename, 'r'), filename, content_type.strip())
-    except:
+    except ValueError:
         raise argparse.ArgumentError("Invalid value for %r" % (text))
 
 
diff --git a/tools/mock-meta.py b/tools/mock-meta.py
index a0d9944..82ccd69 100755
--- a/tools/mock-meta.py
+++ b/tools/mock-meta.py
@@ -259,7 +259,7 @@ class MetaDataHandler(object):
                 try:
                     key_id = int(mybe_key)
                     key_name = key_ids[key_id]
-                except:
+                except KeyError:
                     raise WebException(hclient.BAD_REQUEST,
                                        "Unknown key id %r" % mybe_key)
                 # Extract the possible sub-params

Follow ups