mogrifier.evaluate_annotation passes a lazy map object to utils.common_member, which tests membership with i in l2 inside a list comprehension. The first i in l2 consumes the one-shot iterator; every subsequent lookup sees it empty. When the resolved selection list (selections[long_name]) has more than one element and a non-matching element is iterated before a matching one, common_member returns [] and the [ANY …] section is wrongly deleted.
Root cause
server/scripts/sequence-doc/src/mogrifier.py:390 (ANY branch):
long_compare = map(lambda name: name_map[name], short_compare)
...
elif not utils.common_member(selections[long_name], long_compare):
server/scripts/sequence-doc/src/utils.py:6:
def common_member(l1, l2) -> bool:
return [i for i in l1 if i in l2] # `i in l2` consumes l2 when l2 is an iterator
Fix
Materialize before membership testing — either:
# mogrifier.py, ANY branch
long_compare = [name_map[name] for name in short_compare]
or harden the helper:
# utils.py
def common_member(l1, l2) -> bool:
l2 = list(l2)
return [i for i in l1 if i in l2]
Sub-issue: Sequence doc tests not integrated in CI
It turns out that server/scripts/sequence-doc/tests/test_sequence_doc.py is not part of the CI workflow.
This ticket will integrate it and add the unit tests for the issue above.
mogrifier.evaluate_annotationpasses a lazymapobject toutils.common_member, which tests membership withi in l2inside a list comprehension. The firsti in l2consumes the one-shot iterator; every subsequent lookup sees it empty. When the resolved selection list (selections[long_name]) has more than one element and a non-matching element is iterated before a matching one,common_memberreturns[]and the[ANY …]section is wrongly deleted.Root cause
server/scripts/sequence-doc/src/mogrifier.py:390(ANY branch):server/scripts/sequence-doc/src/utils.py:6:Fix
Materialize before membership testing — either:
or harden the helper:
Sub-issue: Sequence doc tests not integrated in CI
It turns out that
server/scripts/sequence-doc/tests/test_sequence_doc.pyis not part of the CI workflow.This ticket will integrate it and add the unit tests for the issue above.