Skip to content

Commit 28b649e

Browse files
committed
Refactor assertion to be more future proof
1 parent 1de757d commit 28b649e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

boltstub/packstream.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from codecs import decode
2121
import inspect
2222
from io import BytesIO
23+
import re
2324
from struct import pack as struct_pack
2425
from struct import unpack as struct_unpack
2526

@@ -125,7 +126,12 @@ def __repr__(self):
125126

126127
def __eq__(self, other):
127128
try:
128-
if self.tag in (StructTagV1.path, StructTagV2.path):
129+
assert all(
130+
StructTagV1.path == value.path
131+
for key, value in locals().items()
132+
if re.match(r"^StructTagV[1-9]\d*$", key)
133+
)
134+
if self.tag == StructTagV1.path:
129135
# path struct => order of nodes and rels is irrelevant
130136
return (other.tag == self.tag
131137
and len(other.fields) == 3

0 commit comments

Comments
 (0)