From 7aa506d544cff299734444d996c8b0f6117ddd83 Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Fri, 19 Jul 2024 13:13:08 +0200
Subject: [PATCH] type(A) == X -> isinstance(A, X)

---
 prog/communication.py | 2 +-
 prog/data_utils.py    | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/prog/communication.py b/prog/communication.py
index bfcb63b..e0b37db 100644
--- a/prog/communication.py
+++ b/prog/communication.py
@@ -190,7 +190,7 @@ class FuncCaller:
 
     async def _server_caller_(self, in_head, in_data_raw, connection_controll):
         func_name = in_head["func_name"]
-        assert type(func_name) == str and func_name[0] != '_'
+        assert type(func_name) is str and func_name[0] != '_'
         f = getattr(self, func_name)
         in_data = cbor2.loads(in_data_raw)
         r = await f(*in_data['args'], **in_data['kwargs'])
diff --git a/prog/data_utils.py b/prog/data_utils.py
index 2789c13..525bc13 100644
--- a/prog/data_utils.py
+++ b/prog/data_utils.py
@@ -12,13 +12,13 @@ _shape_matching_time = 0
 
 
 async def unzip_parse(data):
-    if type(data) == dict:
+    if isinstance(data, dict):
         assert len(data) == 1
         data = list(data.values())[0]
-    if type(data) == bytes and data.startswith(b'\x1f\x8b'):
+    if isinstance(data, bytes) and data.startswith(b'\x1f\x8b'):
             proc = await asyncio.create_subprocess_exec("gunzip", stdout=asyncio.subprocess.PIPE, stdin=asyncio.subprocess.PIPE)
             data, stderr = await proc.communicate(data)
-    if type(data) == bytes and data.startswith(b'(\xb5/\xfd'):
+    if isinstance(data, bytes) and data.startswith(b'(\xb5/\xfd'):
             proc = await asyncio.create_subprocess_exec("unzstd", stdout=asyncio.subprocess.PIPE, stdin=asyncio.subprocess.PIPE)
             data, stderr = await proc.communicate(data)
     return json.loads(data)
-- 
GitLab