<#20576 2.20 runs ruff and yapf on BUILD files wit...
# github-notifications
c
#20576 2.20 runs ruff and yapf on BUILD files without opting in to them Issue created by huonw Describe the bug The default behaviour of
pants update-build-files ::
seems to have changed in 2.20, compared to 2.19. In particular, it seems to now build and run yapf and ruff, in addition to black, without opting in to the ruff or yapf formatters via the
pants.backend.build_files.fmt.*
backends. (https://www.pantsbuild.org/2.20/docs/using-pants/key-concepts/backends#available-stable-backends) Reproducer:
Copy code
cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.20.0a0"
backend_packages = []
EOF

# https://docs.astral.sh/ruff/formatter/black/#single-element-tuples-are-always-parenthesized
echo '(1, 2),' > BUILD

pants update-build-files ::
This sets up a build file that has different expected formatting for black vs. ruff by abuse a difference between them. Running with
PANTS_VERSION=2.19.0 bash run.sh
(or anything up to
PANTS_VERSION=2.20.0.dev7 bash run.sh
) has output:
Copy code
12:37:40.96 [INFO] Initializing scheduler...
12:37:41.14 [INFO] Scheduler initialized.
12:37:45.89 [INFO] Starting: Building black.pex from <resource://pants.backend.python.lint.black/black.lock>
12:37:46.76 [INFO] Completed: Building black.pex from <resource://pants.backend.python.lint.black/black.lock>
12:37:47.37 [INFO] No required changes to BUILD files found.However, there may still be deprecations that `update-build-files` doesn't know how to fix. See <https://www.pantsbuild.org/v2.19/docs/upgrade-tips> for upgrade tips.
Notably: • builds black • doesn't reformat Running with
bash run.sh
has output:
Copy code
PANTS_LOCAL_CACHE=false  bash run.sh
12:39:35.21 [INFO] Initializing scheduler...
12:39:35.39 [INFO] Scheduler initialized.
...

12:39:37.04 [INFO] Starting: Building black.pex from <resource://pants.backend.python.lint.black/black.lock>
12:39:37.82 [INFO] Completed: Building black.pex from <resource://pants.backend.python.lint.black/black.lock>
12:39:38.11 [INFO] Starting: Building yapf.pex from <resource://pants.backend.python.lint.yapf/yapf.lock>
12:39:38.86 [INFO] Completed: Building yapf.pex from <resource://pants.backend.python.lint.yapf/yapf.lock>
12:39:38.97 [INFO] Starting: Building ruff.pex from <resource://pants.backend.python.lint.ruff/ruff.lock>
12:39:39.88 [INFO] Completed: Building ruff.pex from <resource://pants.backend.python.lint.ruff/ruff.lock>
Updated BUILD:
  - Format with Ruff
Notably: • builds black and ruff and yapf • reformats with ruff Pants version 2.20.0a0 This seems to be a regression between that and 2.20.0.dev7 likely related to #20411. • https://github.com/pantsbuild/pants/releases/tag/release_2.20.0a0release_2.20.0.dev7...release_2.20.0a0 OS macOS Additional info N/A pantsbuild/pants