tall-battery-32825
03/05/2025, 7:45 PMpants fix :: on my repository, and Black fails with the following error:
ProcessExecutionFailure: Process 'Run Black on 2 files.' failed with exit code 123.
stdout:
stderr:
error: cannot format v1/main.py: cannot use --safe with this file; failed to parse source file AST: invalid syntax (<unknown>, line 17)
This could be caused by running Black with an older Python version that does not support new syntax used in your source file.
Oh no! 💥 💔 💥
1 file left unchanged, 1 file failed to reformat.
Relevant Config:
• Pants version: 2.24.2
• Backends: python, mypy, autoflake, black, isort
• Interpreter constraints:
â—¦ `python-default`: CPython 3.10.15
â—¦ `v2`: CPython 3.11.11
• Resolves:
◦ python-default → 3.10.15
◦ v2 → 3.11.11
◦ mypy → Separate resolve
• Source roots: /v1, /v2
I think black defaults to using python 3.8 or 3.9 which does not support match statements, which is where it is breaking.
So I created a lockfile for black with just the black requirement and it is still failing. How can I make sure black runs with the proper python for the partition?
Thanks!tall-battery-32825
03/05/2025, 7:46 PMtall-battery-32825
03/05/2025, 7:48 PMtall-battery-32825
03/06/2025, 8:52 PMpants fix v1:: it works. I can also run pants fix v2:: afterwards and it works.