PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
530 stars 62 forks source link

IndexError: list index out of range on pre-commit #151

Closed bellini666 closed 1 year ago

bellini666 commented 1 year ago

Got this traceback when running pre-commit run -a. Don't know exactly what file is giving this issue:

Traceback (most recent call last):
  File "/home/bellini/dev/2u/backend/.venv/bin/docformatter", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/__main__.py", line 71, in main
    return _main(
           ^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/__main__.py", line 61, in _main
    return formator.do_format_files()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/format.py", line 156, in do_format_files
    result = self._do_format_file(filename)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/format.py", line 189, in _do_format_file
    formatted_source = self._do_format_code(source)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/format.py", line 234, in _do_format_code
    code = self._format_code(source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/format.py", line 299, in _format_code
    token_string = self._do_format_docstring(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/format.py", line 406, in _do_format_docstring
    description = _syntax.wrap_description(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/syntax.py", line 272, in wrap_description
    text = do_preserve_links(text, indentation, wrap_length)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bellini/dev/2u/backend/.venv/lib/python3.11/site-packages/docformatter/syntax.py", line 97, in do_preserve_links
    url = f"{indentation}" + url.strip().split(sep=" ")[1].strip()
bellini666 commented 1 year ago

obs. using python 3.11

weibullguy commented 1 year ago

@bellini666 I got ahead of myself releasing 1.5.0 to PyPi without sufficient testing. Before I cause users anymore headaches, I'm providing release candidates for the brave to use and provide feedback. If you'd like to use the next release candidate that should resolve your issue, you can install it with pip:

pip install git+https://github.com/PyCQA/docformatter.git@v1.6.0.rc1

bellini666 commented 1 year ago

Hey @weibullguy , I tried to install it but I can't because of the charset_normalizer dependency. There are at least 3 packages that depends on charset_normalized < 3.0

Is there a way to support charset_normalized 2.x too?