mrirecon / bart

BART: Toolbox for Computational Magnetic Resonance Imaging
https://mrirecon.github.io/bart/
BSD 3-Clause "New" or "Revised" License
291 stars 161 forks source link

Fix incorrect handling of keyword arguments #306

Closed fyrdahl closed 1 year ago

fyrdahl commented 1 year ago

This PR solves a bug introduced in 4ded5814aa6f6147ebc525ce82b131730e2725eb

Incorrect grouping of expressions meant that if the keyword argument had more than 1 character, the code would append the double dashes, but not the keyword argument. As far as I can tell, there is no current tool that would run into this problem, but I believe it's good manners to fix the bug I introduced.

Previous behavior:

kwargs = ['hello', 'w']
args_kw = ["--" if len(kw) > 1 else "-" + kw for kw in kwargs]
print(args_kw)

Output: ['--', '-w']

Fixed in this PR:

kwargs = ['hello', 'w']
args_kw = [("--" if len(kw) > 1 else "-") + kw for kw in kwargs]
print(args_kw)

Output: ['--hello', '-w']