codespell-project / codespell

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

Test multi-suggestion-ending-in-comma with pre-commit hook #3526

Open corneliusroemer opened 3 weeks ago

corneliusroemer commented 3 weeks ago

It should be easy to write a little sed script to auto-fix/format this:

codespell_lib/tests/test_dictionary.py:80: in test_dictionary_formatting
    raise AssertionError(msg)
E   AssertionError: 
E   error disturbative: multiple corrections must end with trailing ","
sed '/,/s/,*$/,/' filename

This should:

corneliusroemer commented 3 weeks ago

Better: first remove all trailing commas, then readd if there's a comma in the line. This also removes unnecessary trailing commas

sed -e 's/,*$//' -e '/,/s/$/,/' filename
DimitriPapadopoulos commented 3 weeks ago

Actually, any item after the last comma is supposed to be a comment. I'm not a huge fan of this functionality, but I think we shouldn't modify this until we have a better and documented way to comment.

corneliusroemer commented 3 weeks ago

I see! I don't think there's a single comment like this at the moment