Skip to content

IndexError: string index out of range #759

Open
@pmvd

Description

@pmvd

autopep8 -i model.py
Traceback (most recent call last):
File "/.venv/bin/autopep8", line 8, in
sys.exit(main())
^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 4590, in main
results = fix_multiple_files(args.files, args, sys.stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 4485, in fix_multiple_files
ret = _fix_file((name, options, output))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 4455, in _fix_file
return fix_file(*parameters)
^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 3629, in fix_file
fixed_source = fix_lines(fixed_source, options, filename=filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 3609, in fix_lines
fixed_source = fix.fix()
^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 623, in fix
results = _execute_pep8(pep8_options, self.source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 3021, in _execute_pep8
checker.check_all()
File "/.venv/lib/python3.12/site-packages/pycodestyle.py", line 2115, in check_all
self.check_logical()
File "/.venv/lib/python3.12/site-packages/pycodestyle.py", line 1973, in check_logical
mapping = self.build_tokens_line()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/pycodestyle.py", line 1956, in build_tokens_line
prev_text = self.lines[prev_row - 1][prev_col - 1]
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
IndexError: string index out of range

Python Code

private

Command Line and Configuration

.pep8, setup.cfg, ...

[pep8]

Command Line

$ autopep8 

Your Environment

  • Python version: Python 3.12.4
  • autopep8 version: autopep8 2.3.1 (pycodestyle: 2.12.0)
  • Platform: linux

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions