Skip to content

Commit

Permalink
style: Compare Python types with is, not ==
Browse files Browse the repository at this point in the history
The right way to compare primitive types in Python is to use the exact
comparison `is`.

This shuts up the flake8 linter, currently complaining on master branch.
  • Loading branch information
adrienverge committed Aug 28, 2023
1 parent 32e1906 commit 9b9676f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions localstripe/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def try_convert_to_bool(arg):


def try_convert_to_int(arg):
if type(arg) == int:
if type(arg) is int:
return arg
elif type(arg) in (str, float):
try:
Expand All @@ -93,7 +93,7 @@ def try_convert_to_int(arg):


def try_convert_to_float(arg):
if type(arg) == float:
if type(arg) is float:
return arg
elif type(arg) in (str, int):
try:
Expand Down
2 changes: 1 addition & 1 deletion localstripe/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def auth_middleware(request, handler):
data = unflatten_data(request.query)

if not is_auth and accept_key_in_post_data:
if ('key' in data and type(data['key']) == str and
if ('key' in data and type(data['key']) is str and
data['key'].startswith('pk_')):
is_auth = True

Expand Down

0 comments on commit 9b9676f

Please sign in to comment.