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

Proposed by Joshua Powers
Status: Merged
Merged at revision: 5f14a0b1ca3079e4ab43d615840866a4b7d8df6a
Proposed branch: ~powersj/cloud-init:pycodestyle
Merge into: cloud-init:master
Diff against target: 26 lines (+2/-2)
2 files modified
tools/make-mime.py (+1/-1)
tools/mock-meta.py (+1/-1)
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+316042@code.launchpad.net

Commit message

pycodestyle cleanup

Description of the change

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.

To post a comment you must log in.

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/make-mime.py b/tools/make-mime.py
2index 1272712..f6a7204 100755
3--- a/tools/make-mime.py
4+++ b/tools/make-mime.py
5@@ -22,7 +22,7 @@ def file_content_type(text):
6 try:
7 filename, content_type = text.split(":", 1)
8 return (open(filename, 'r'), filename, content_type.strip())
9- except:
10+ except ValueError:
11 raise argparse.ArgumentError("Invalid value for %r" % (text))
12
13
14diff --git a/tools/mock-meta.py b/tools/mock-meta.py
15index a0d9944..82ccd69 100755
16--- a/tools/mock-meta.py
17+++ b/tools/mock-meta.py
18@@ -259,7 +259,7 @@ class MetaDataHandler(object):
19 try:
20 key_id = int(mybe_key)
21 key_name = key_ids[key_id]
22- except:
23+ except KeyError:
24 raise WebException(hclient.BAD_REQUEST,
25 "Unknown key id %r" % mybe_key)
26 # Extract the possible sub-params

Subscribers

People subscribed via source and target branches