Closed hmmbug closed 8 years ago
@hmmbug This mostly LGTM. Could you please add a commit to remove the warning lines:
warnings.warn( ...
These are now superfluous and the call site can choose to log the exception. A few tests will also need to be updated.
This change will require a major version bump as it changes the contract for the APIs, but totally agree that this is more idiomatic Python.
Thanks!
Updated as per feedback above and Issue #43
@fredsadaghiani I've not updated the version number. I'll leave that for you & your colleagues to decide about 1.x or 2.0. Thanks.
Thanks @hmmbug, this LGTM. I'm going to merge to master and add a few commits to cut a new release.
FYI, v2.0.0.0 has been released: https://pypi.python.org/pypi/Sift
This pull request is to change the error behaviour for track(), score(), label() and unlabel() methods to be more pythonic in raising exceptions instead of returning them.
Currently it is necessary to call a method and check the response type as we don't know if we'll get a Response object come back or a subclass of Exception, eg. from the docs (https://siftscience.com/developers/docs/python/automation-apis/score-api):
But if score() returns an exception then the is_ok() method on the second line doesn't exist and an AttributeError exception is raised.
A more complete way to error check would be this awkward mixture of try/except and if:
but with the pull request we can just do it idiomatically: