Skip to content

error when upgraded python from 3.11 to 3.13 #1279

@stav-bitanski

Description

@stav-bitanski

Recreate issue:

  1. be in python 3.11
  2. use pyenv to download and change to python 3.13
  3. remove .venv
  4. create new .venv with poetry shell
  5. poetry update
  6. run yapf again

Error:

Traceback (most recent call last):

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/yapflib/yapf_api.py", line 198, in FormatCode

    tree = pytree_utils.ParseCodeToTree(unformatted_source)

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/pytree/pytree_utils.py", line 113, in ParseCodeToTree

    tree = parser_driver.parse_string(code, debug=False)

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 187, in parse_string

    return self.parse_tokens(tokens, debug)

           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf_third_party/_ylib2to3/pgen2/driver.py", line 156, in parse_tokens

    if p.addtoken(type, value, (prefix, start)):

       ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf_third_party/_ylib2to3/pgen2/parse.py", line 230, in addtoken

    return self._addtoken(ilabel, type, value, context)

           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf_third_party/_ylib2to3/pgen2/parse.py", line 313, in _addtoken

    raise ParseError('bad input', type, value, context)

yapf_third_party._ylib2to3.pgen2.parse.ParseError: bad input: type=1, value='DEPLOY_ENV', context=('', (26, 66))



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/__init__.py", line 238, in _FormatFile

    reformatted_code, encoding, has_change = yapf_api.FormatFile(

                                             ~~~~~~~~~~~~~~~~~~~^

        filename,

        ^^^^^^^^^

    ...<3 lines>...

        print_diff=print_diff,

        ^^^^^^^^^^^^^^^^^^^^^^

        logger=logging.warning)

        ^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/yapflib/yapf_api.py", line 88, in FormatFile

    reformatted_source, changed = FormatCode(

                                  ~~~~~~~~~~^

        original_source,

        ^^^^^^^^^^^^^^^^

    ...<2 lines>...

        lines=lines,

        ^^^^^^^^^^^^

        print_diff=print_diff)

        ^^^^^^^^^^^^^^^^^^^^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/yapflib/yapf_api.py", line 201, in FormatCode

    raise errors.YapfError(errors.FormatErrorMsg(e))

                           ~~~~~~~~~~~~~~~~~~~~~^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/yapflib/errors.py", line 37, in FormatErrorMsg

    return '{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)

                                 ~~~~~~^^^

IndexError: tuple index out of range



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/home/jenkins/.pyenv/versions/3.13.3/lib/python3.13/concurrent/futures/process.py", line 254, in _process_worker

    r = call_item.fn(*call_item.args, **call_item.kwargs)

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/__init__.py", line 248, in _FormatFile

    raise errors.YapfError(errors.FormatErrorMsg(e))

                           ~~~~~~~~~~~~~~~~~~~~~^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/yapflib/errors.py", line 37, in FormatErrorMsg

    return '{}:{}:{}: {}'.format(e.args[1][0], e.args[1][1], e.args[1][2], e.msg)

                                 ~~~~~~^^^

IndexError: tuple index out of range

"""



The above exception was the direct cause of the following exception:



Traceback (most recent call last):

  File "/home/jenkins/.virtualenvs/bin/yapf", line 8, in <module>

    sys.exit(run_main())

             ~~~~~~~~^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/__init__.py", line 377, in run_main

    sys.exit(main(sys.argv))

             ~~~~^^^^^^^^^^

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/__init__.py", line 136, in main

    changed = FormatFiles(

        files,

    ...<7 lines>...

        verbose=args.verbose,

        print_modified=args.print_modified)

  File "/home/jenkins/.virtualenvs/lib/python3.13/site-packages/yapf/__init__.py", line 211, in FormatFiles

    changed |= future.result()

               ~~~~~~~~~~~~~^^

  File "/home/jenkins/.pyenv/versions/3.13.3/lib/python3.13/concurrent/futures/_base.py", line 449, in result

    return self.__get_result()

           ~~~~~~~~~~~~~~~~~^^

  File "/home/jenkins/.pyenv/versions/3.13.3/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result

    raise self._exception

IndexError: tuple index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions