Skip to content

test_codemod_formatter_error_input fails with black 24.10.0 #1220

@stanislavlevin

Description

@stanislavlevin

test_codemod_formatter_error_input test fails against black 24.10.0 with:

FAIL: test_codemod_formatter_error_input (codemod.tests.test_codemod_cli.TestCodemodCLI.test_codemod_formatter_error_input)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/src/RPM/BUILD/python3-module-libcst-1.4.0/libcst/codemod/tests/test_codemod_cli.py", line 44, in test_codemod_formatter_error_input
    self.assertIn(
AssertionError: 'error: cannot format -: Cannot parse: 13:10:     async with AsyncExitStack() as stack:' not found in 'Calculating full-repo metadata...\nExecuting codemod...\nerror: cannot format -: Cannot parse for target version Python 3.6: 13:10:     async with AsyncExitStack() as stack:\n\nOh no! 💥 💔 💥\n1 file failed to reformat.\n\r\x1b[2KCodemodding /usr/src/RPM/BUILD/python3-module-libcst-1.4.0/libcst/codemod/tests/codemod_formatter_error_input.py.txt\n# Copyright (c) Meta Platforms, Inc. and affiliates.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n#\n# pyre-strict\n\nfrom contextlib import AsyncExitStack\n\n\ndef fun() -> None:\n    # this is an explicit syntax error to cause formatter error\n    async with AsyncExitStack() as stack:\n        stack\n\nTraceback (most recent call last):\n  File "/usr/src/RPM/BUILD/python3-module-libcst-1.4.0/.run_venv/lib64/python3/site-packages/libcst/codemod/_cli.py", line 316, in _execute_transform\n    newcode = invoke_formatter(config.formatter_args, newcode)\n              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/usr/src/RPM/BUILD/python3-module-libcst-1.4.0/.run_venv/lib64/python3/site-packages/libcst/codemod/_cli.py", line 57, in invoke_formatter\n    subprocess.check_output(\n  File "/usr/lib64/python3.12/subprocess.py", line 466, in check_output\n    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/usr/lib64/python3.12/subprocess.py", line 571, in run\n    raise CalledProcessError(retcode, process.args,\nsubprocess.CalledProcessError: Command \'[\'/usr/src/RPM/BUILD/python3-module-libcst-1.4.0/.run_venv/bin/black\', \'--target-version\', \'py36\', \'-\']\' returned non-zero exit status 123.\n\nFailed to codemod /usr/src/RPM/BUILD/python3-module-libcst-1.4.0/libcst/codemod/tests/codemod_formatter_error_input.py.txt\n\n\r\x1b[2K0.31s 0% complete, [calculating] estimated for 1 files to go...\r\x1b[2KFinished codemodding 1 files!\n - Transformed 0 files successfully.\n - Skipped 0 files.\n - Failed to codemod 1 files.\n - 0 warnings were generated.\n'

----------------------------------------------------------------------

https://github.com/psf/black/blob/main/CHANGES.md#output

Added Python target version information on parse error (psf/black#4378)

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