cutadapt icon indicating copy to clipboard operation
cutadapt copied to clipboard

Fix bug in report.py when dealing with empty list

Open y9c opened this issue 1 year ago • 3 comments

cutseq report this error when eranges is None.

  File ".micromamba/lib/python3.12/site-packages/cutadapt/report.py", line 246, in as_json
    self._adapter_statistics_as_json(
  File ".micromamba/lib/python3.12/site-packages/cutadapt/report.py", line 302, in _adapter_statistics_as_json
    "error_lengths": make_line(eranges),
                     ^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

y9c avatar Aug 28 '24 02:08 y9c

close https://github.com/marcelm/cutadapt/issues/804

y9c avatar Aug 28 '24 02:08 y9c

How did you trigger this? Would be good to have a test as well.

marcelm avatar Sep 13 '24 08:09 marcelm

Oh, you’re calling _adapter_statistics_as_json with one_line=False.

Your suggested fix is not correct because error_lengths needs to be null when not available as documented.

I think the correct fix is to change:

        make_line = OneLine if one_line else list

to

        make_line = OneLine if one_line else lambda x: x

marcelm avatar Sep 13 '24 08:09 marcelm