calling mgf.read() with usage of source keyword raises IndexError

Issue #24 resolved
Anonymous created an issue

If I run

mgf.read(source=obsS_MGF_filePath, use_header=True, convert_arrays=1, read_charges=False, dtype=float)

I get

File "/usr/local/lib/python3.5/dist-packages/pyteomics/auxiliary.py", line 531, in helper
    return FileReader(args[0], _mode, _func, True, args[1:], kwargs, kwargs.pop('encoding', None))
IndexError: tuple index out of range

But if I run without explicitly writing the source keyword:

mgf.read(obsS_MGF_filePath, use_header=True, convert_arrays=1, read_charges=False, dtype=float)

everything works just fine. The problem is that the args tuple is empty when you use the source keyword. I strongly advise against using the args tuple in this way, because you are hardcoding your argument order while making it look like you are not (because you specify keywords).

Comments (5)

  1. Joris Van Houtven

    I created this issue but the message formatting got messed up. At least for me they are not visible. The missing lines of code are

    mgf.read(source=obsS_MGF_filePath, use_header=True, convert_arrays=1, read_charges=False, dtype=float)

    and

    mgf.read(obsS_MGF_filePath, use_header=True, convert_arrays=1, read_charges=False, dtype=float)

  2. Log in to comment