Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bellini666 opened this issue Jan 16, 2023 · 3 comments · Fixed by #152
Closed

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

bellini666 opened this issue Jan 16, 2023 · 3 comments · Fixed by #152
Labels
C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) P: bug PEP 257 violation or existing functionality that doesn't work as documented
Milestone

Comments

@bellini666
Copy link

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()
@github-actions github-actions bot added the fresh This is a new issue label Jan 16, 2023
@bellini666
Copy link
Author

obs. using python 3.11

@weibullguy weibullguy added P: bug PEP 257 violation or existing functionality that doesn't work as documented C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) and removed fresh This is a new issue labels Jan 17, 2023
@weibullguy weibullguy added this to the v1.6.0 milestone Jan 19, 2023
@weibullguy
Copy link
Member

@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/[email protected]

@bellini666
Copy link
Author

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?

huonw added a commit to pantsbuild/pants that referenced this issue Feb 29, 2024
…ip_version = 24.0, for Py 3.12 support (#20365)

This does three things to fix #20354 and give Pants Python 3.12 support
by default:

- update the default `[python].pip_version` value to `24.0` (from
`23.1.2`), which is the current latest and is after 23.2, which is the
first that supports Python 3.12
- run `pants run build-support/bin/generate_builtin_lockfiles.py --
--all-python` to update all tool lockfiles... this involves updating
many tools, as a Big Bang, which is potentially unhelpful.
- to make this work, `docformatter` has to be restricted to the current
version 1.4: 1.5.1 (the newest version that satisfies the old
constraints) crashes on Pants itself
(PyCQA/docformatter#151), while 1.7.5 (the
newest version) also doesn't work on Pants (#20498)

Here's a list of (as best I can tell), the changes in versions for the
"main" requirement for each subsystem:

| subsystem options scope | main requirement | old version | new version |
|-------------------------|------------------|-------------|-------------|
| `helm-k8s-parser`       | `hikaru`         | 0.11.0b0    | 0.16.0b0    |
| `helm-post-renderer`    | `yamlpath`       | 3.7.0       | 3.8.1       |
| `autoflake`             | `autoflake`      | 2.0.1       | 2.1.1       |
| `bandit`                | `bandit`         | 1.7.4       | 1.7.5       |
| `black`                 | `black`          | 23.1.0      | 23.3.0      |
| `pyupgrade`             | `pyupgrade`      | 3.3.1       | 3.3.2       |
| `ruff`                  | `ruff`           | 0.2.1       | 0.2.2       |
| `yapf`                  | `yapf`           | 0.32.0      | 0.40.2      |
| `coverage-py`           | `coverage`       | 7.2.1       | 7.2.7       |
| `debugpy`               | `debugpy`        | 1.6.6       | 1.6.7.post1 |
| `mypy`                  | `mypy`           | 1.1.1       | 1.4.1       |
| `terraform-hcl2-parser` | `python-hcl2`    | 4.3.0       | 4.3.2       |
| `yamllint`              | `yamllint`       | 1.29.0      | 1.32.0      |

There's numerous other transitive dependencies updated too, including in
subsystems for which the main requirement hasn't changed and aren't
listed above.

I haven't checked changelogs for any of these.

I've confirmed that running the reproducer from #20354 with this code
now works. The commits are 'sensible'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) P: bug PEP 257 violation or existing functionality that doesn't work as documented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants