Skip to content

Commit 8726330

Browse files
committed
chore(pb): pb3 like check_type, ProtoStruct repr & debug
1 parent b4ddbe7 commit 8726330

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lagrange/utils/binary/protobuf/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def check_type(value: Any, typ: Any) -> bool:
164164
return check_type(value, get_args(typ)[0]) if value is not None else True
165165
if isinstance(value, typ):
166166
return True
167-
return False # or True if value is None else False
167+
return True if value is None else False # proto3 std
168168

169169

170170
_unevaluated_classes: set[type["ProtoStruct"]] = set()
@@ -255,7 +255,7 @@ def __repr__(self) -> str:
255255
if k.startswith("_"):
256256
continue
257257
attrs += f"{k}={v!r}, "
258-
return f"{self.__class__.__name__}({attrs})"
258+
return f"{self.__class__.__name__}({attrs[:-2]})"
259259

260260
def encode(self) -> bytes:
261261
pb_dict: NT = {}
@@ -289,7 +289,7 @@ def decode(cls, data: bytes) -> Self:
289289
}
290290

291291
if pb_dict and cls.__proto_debug__: # unhandled tags
292-
pass
292+
print(f"DEBUG: unhandled tags '{pb_dict}' on {cls}")
293293
return cls(True, **kwargs)
294294

295295

0 commit comments

Comments
 (0)