Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in report.py when dealing with empty list #803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

y9c
Copy link
Contributor

@y9c y9c commented Aug 28, 2024

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
Copy link
Contributor Author

y9c commented Aug 28, 2024

close #804

@marcelm
Copy link
Owner

marcelm commented Sep 13, 2024

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

@marcelm
Copy link
Owner

marcelm commented Sep 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants