Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sharpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = (0, 9, 5)
VERSION = (0, 9, 6)
7 changes: 3 additions & 4 deletions sharpy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ def make_request(self, path, params=None, data=None, method=None):
cleaned_data = data.copy()
try:
del cleaned_data['subscription[ccCardCode]']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can use cleaned_data.pop('subscription[ccCardCode]') which will remove the value without a KeyError.

ccNum = cleaned_data['subscription[ccNumber]']
cleaned_data['subscription[ccNumber]'] = ccNum[-4:]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is generally bad form to use exceptions for flow control. You should instead do:

if 'subscription[ccNumber]' in cleaned_data:
    cleaned_data['subscription[ccNumber]'] = cleaned_data[subscription[ccNumber]][:-4]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trust me, I'm not considering keeping this band-aid around. I'll keep these in mind next time I run into these cases.

except KeyError:
pass
ccNum = cleaned_data['subscription[ccNumber]']
cleaned_data['subscription[ccNumber]'] = ccNum[-4:]

cleaned_data['subscription[ccNumber]'] = None

client_log.debug('Request Method: %s' % method)
client_log.debug('Request Body (Cleaned Data): %s' % cleaned_data)
Expand Down