Skip to content

Allow comments and empty lines in dictionary #3901

Description

@vries

I'd like to add a comment to a dictionary (similar to how issue #2063 requests this for ignore-words files):

 gdbsever->gdbserver
 tcllint->tclint
 recordered->recorded
+# Comment.

but it makes codespell crash:

Traceback (most recent call last):
  File "/home/vries/.cache/pre-commit/repoxmktmlyg/py_env-python3.13/bin/codespell", line 6, in <module>
    sys.exit(_script_main())
             ~~~~~~~~~~~~^^
  File "/home/vries/.cache/pre-commit/repoxmktmlyg/py_env-python3.13/lib/python3.13/site-packages/codespell_lib/_codespell.py", line 1234, in _script_main
    return main(*sys.argv[1:])
  File "/home/vries/.cache/pre-commit/repoxmktmlyg/py_env-python3.13/lib/python3.13/site-packages/codespell_lib/_codespell.py", line 1363, in main
    build_dict(dictionary, misspellings, ignore_words)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vries/.cache/pre-commit/repoxmktmlyg/py_env-python3.13/lib/python3.13/site-packages/codespell_lib/_spellchecker.py", line 57, in build_dict
    [key, data] = line.split("->")
    ^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Likewise, empty lines:

 gdbsever->gdbserver
 tcllint->tclint
+
 recordered->recorded

make codespell crash.

For now, for adding comments I'm making do with this hack:

 gdbsever->gdbserver
 tcllint->tclint
 recordered->recorded
+-># Comment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions