From 9b9676f4f9dd230bc4945e3869255871317eb877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Mon, 28 Aug 2023 11:33:27 +0200 Subject: [PATCH] style: Compare Python types with `is`, not `==` 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. --- localstripe/resources.py | 4 ++-- localstripe/server.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/localstripe/resources.py b/localstripe/resources.py index 6e04f86d..40de8ad1 100644 --- a/localstripe/resources.py +++ b/localstripe/resources.py @@ -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: @@ -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: diff --git a/localstripe/server.py b/localstripe/server.py index 787f202d..ea63ce23 100644 --- a/localstripe/server.py +++ b/localstripe/server.py @@ -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