From b3fd0d37b27483c41ced0e8893426466514288af Mon Sep 17 00:00:00 2001 From: eynzhang <2427928+eynzhang@users.noreply.github.com> Date: Thu, 3 Dec 2020 17:14:29 +0800 Subject: [PATCH] Update '== True' to better way --- huobi/connection/impl/websocket_watchdog.py | 2 +- huobi/connection/restapi_sync_client.py | 6 +++--- huobi/connection/subscribe_client.py | 2 +- huobi/connection/websocket_req_client.py | 2 +- performance/testcase.py | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/huobi/connection/impl/websocket_watchdog.py b/huobi/connection/impl/websocket_watchdog.py index c591b6f..f755def 100644 --- a/huobi/connection/impl/websocket_watchdog.py +++ b/huobi/connection/impl/websocket_watchdog.py @@ -10,7 +10,7 @@ def watch_dog_job(*args): watch_dog_obj = args[0] for idx, websocket_manage in enumerate(watch_dog_obj.websocket_manage_list): - if websocket_manage.request.auto_close == True: # setting auto close no need reconnect + if websocket_manage.request.auto_close: # setting auto close no need reconnect pass elif websocket_manage.state == ConnectionState.CONNECTED: if watch_dog_obj.is_auto_connect: diff --git a/huobi/connection/restapi_sync_client.py b/huobi/connection/restapi_sync_client.py index eae1f63..22e2207 100644 --- a/huobi/connection/restapi_sync_client.py +++ b/huobi/connection/restapi_sync_client.py @@ -26,7 +26,7 @@ def __init__(self, **kwargs): self.__server_url = kwargs.get("url", get_default_server_url(None)) self.__init_log = kwargs.get("init_log", None) self.__performance_test = kwargs.get("performance_test", None) - if self.__init_log and self.__init_log == True: + if self.__init_log and self.__init_log: logger = logging.getLogger("huobi-client") logger.setLevel(level=logging.INFO) handler = logging.StreamHandler() @@ -110,7 +110,7 @@ def create_request_post_batch(self, method, url, params, parse): return request def request_process(self, method, url, params, parse): - if self.__performance_test is not None and self.__performance_test == True: + if self.__performance_test is not None and self.__performance_test is True: return self.request_process_performance(method, url, params, parse) else: return self.request_process_product(method, url, params, parse) @@ -133,7 +133,7 @@ def request_process_performance(self, method, url, params, parse): for post batch operation, such as batch create orders[ /v1/order/batch-orders ] """ def request_process_post_batch(self, method, url, params, parse): - if self.__performance_test is not None and self.__performance_test == True: + if self.__performance_test is not None and self.__performance_test is True: return self.request_process_post_batch_performance(method, url, params, parse) else: return self.request_process_post_batch_product(method, url, params, parse) diff --git a/huobi/connection/subscribe_client.py b/huobi/connection/subscribe_client.py index 3a46845..11a6d16 100644 --- a/huobi/connection/subscribe_client.py +++ b/huobi/connection/subscribe_client.py @@ -24,7 +24,7 @@ def __init__(self, **kwargs): self.__secret_key = kwargs.get("secret_key", None) self.__uri = kwargs.get("url", WebSocketDefine.Uri) self.__init_log = kwargs.get("init_log", None) - if self.__init_log and self.__init_log == True: + if self.__init_log and self.__init_log: logger = logging.getLogger("huobi-client") logger.setLevel(level=logging.INFO) handler = logging.StreamHandler() diff --git a/huobi/connection/websocket_req_client.py b/huobi/connection/websocket_req_client.py index e74af07..5e0c07a 100644 --- a/huobi/connection/websocket_req_client.py +++ b/huobi/connection/websocket_req_client.py @@ -22,7 +22,7 @@ def __init__(self, **kwargs): self.__secret_key = kwargs.get("secret_key", None) self.__uri = kwargs.get("url", WebSocketDefine.Uri) self.__init_log = kwargs.get("init_log", None) - if self.__init_log and self.__init_log == True: + if self.__init_log and self.__init_log: logger = logging.getLogger("huobi-client") logger.setLevel(level=logging.INFO) handler = logging.StreamHandler() diff --git a/performance/testcase.py b/performance/testcase.py index f609a13..3ac76be 100644 --- a/performance/testcase.py +++ b/performance/testcase.py @@ -78,7 +78,7 @@ def output_sdk_header(format_str, only_brief): sdk_func_name = "sdk_func_name{format_str}".format(format_str=format_str) run_status = "run_status{format_str}".format(format_str=format_str) - if only_brief == True: + if only_brief: print(delay_server_api_cost, delay_server_req_cost, sdk_api_cost) @@ -132,7 +132,7 @@ def output_sdk_cost(dict_data, format_str, only_brief): run_status_desc = "" - if only_brief == True: + if only_brief: print( sdk_api_delay_desc, sdk_req_delay_desc, @@ -153,7 +153,7 @@ def output_sdk_cost(dict_data, format_str, only_brief): def output_sort_cost(by_key_name, is_sorted=False): global time_cost_detail_list - if is_sorted == True: + if is_sorted: output_list = sorted(time_cost_detail_list, key=lambda e: e.__getitem__(by_key_name), reverse=True) else: output_list = time_cost_detail_list