codespell-project / codespell

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

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

Open corneliusroemer opened 2 months ago

corneliusroemer commented 2 months 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 2 months 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 2 months 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 2 months ago

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