Skip to content

Commit

Permalink
Fix quality issues reported by DeepSource (#572)
Browse files Browse the repository at this point in the history
* Fix quality issues reported by DeepSource

Fixes:
- PYL-C1801: Don't use len() to check for empty sequence
- PYL-W0612: Rename unused variable to `_`
- PYL-C0123: Use isinstance() for checking type

* Reformat code
  • Loading branch information
sauravsrijan authored and ob-stripe committed May 20, 2019
1 parent d599259 commit 2b0b375
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions stripe/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class HTTPClient(object):
def __init__(self, verify_ssl_certs=True, proxy=None):
self._verify_ssl_certs = verify_ssl_certs
if proxy:
if type(proxy) is str:
if isinstance(proxy, str):
proxy = {"http": proxy, "https": proxy}
if not (type(proxy) is dict):
if not isinstance(proxy, dict):
raise ValueError(
"Proxy(ies) must be specified as either a string "
"URL or a dict() with string URL under the"
Expand Down
6 changes: 2 additions & 4 deletions stripe/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ def authorize_url(**params):
@staticmethod
def token(**params):
requestor = api_requestor.APIRequestor(api_base=connect_api_base)
response, api_key = requestor.request(
"post", "/oauth/token", params, None
)
response, _ = requestor.request("post", "/oauth/token", params, None)
return response.data

@staticmethod
def deauthorize(**params):
requestor = api_requestor.APIRequestor(api_base=connect_api_base)
OAuth._set_client_id(params)
response, api_key = requestor.request(
response, _ = requestor.request(
"post", "/oauth/deauthorize", params, None
)
return response.data
2 changes: 1 addition & 1 deletion stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def convert_to_stripe_object(
):
global OBJECT_CLASSES

if len(OBJECT_CLASSES) == 0:
if not OBJECT_CLASSES:
load_object_classes()
types = OBJECT_CLASSES.copy()

Expand Down
2 changes: 1 addition & 1 deletion stripe/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def verify_header(cls, payload, header, secret, tolerance=None):
payload,
)

if len(signatures) == 0:
if not signatures:
raise error.SignatureVerificationError(
"No signatures found with expected scheme "
"%s" % cls.EXPECTED_SCHEME,
Expand Down

0 comments on commit 2b0b375

Please sign in to comment.