codespell-project / codespell

check code for common misspellings
GNU General Public License v2.0
1.84k stars 470 forks source link

Handle multiline options #3400

Closed DimitriPapadopoulos closed 4 months ago

DimitriPapadopoulos commented 4 months ago

Clean up options expecting lists before using them, as they may contain newlines.

Examples:

In all the above cases, the option parsing mechanism keeps the newlines (and spaces) . We need to clean up, by splitting on commas and stripping each resulting item from newlines (and spaces).

Fixes #3399.

Very much related to #2767. Both pull requests introduce an option to flatten the options list after splitting on commas, and both need tests!

Supersedes #3299.

DimitriPapadopoulos commented 4 months ago

@larsoner Would you agree to merge this PR that fixes a codespell bug? Full tests already added.

larsoner commented 4 months ago

@DimitriPapadopoulos I simplified the logic by avoiding the Optional stuff and just always having a List[str] and making use of stuff like any([]) == False, feel free to merge if you're happy with the change