Skip to main content
Version: 2.23 (prerelease)

update-build-files


pants update-build-files [args]

Format and fix safe deprecations in BUILD files.

This does not handle the full Pants upgrade. You must still manually change pants_version in pants.toml and you may need to manually address some deprecations. See https://www.pantsbuild.org/2.23/docs/releases/upgrade-tips for upgrade tips.

Backend: pants.core

Config section: [update-build-files]

Basic options

check

--[no-]update-build-files-check
PANTS_UPDATE_BUILD_FILES_CHECK
pants.toml
[update-build-files]
check = <bool>
default: False

Do not write changes to disk, only write back what would change. Return code 0 means there would be no changes, and 1 means that there would be.

fix_safe_deprecations

--[no-]update-build-files-fix-safe-deprecations
PANTS_UPDATE_BUILD_FILES_FIX_SAFE_DEPRECATIONS
pants.toml
[update-build-files]
fix_safe_deprecations = <bool>
default: True

Automatically fix deprecations, such as target type renames, that are safe because they do not change semantics.

fmt

--[no-]update-build-files-fmt
PANTS_UPDATE_BUILD_FILES_FMT
pants.toml
[update-build-files]
fmt = <bool>
default: True

Format BUILD files using Black, Ruff or Yapf.

Set [black].args / [ruff].args / [yapf].args, [black].config / [ruff].config, [yapf].config , and [black].config_discovery / [ruff].config_discovery, [yapf].config_discovery to change Black's, Ruff's, or Yapf's behavior. Set [black].interpreter_constraints / [ruff].interpreter_constraints / [yapf].interpreter_constraints and [python].interpreter_search_path to change which interpreter is used to run the formatter.

formatter

--update-build-files-formatter=<Formatter>
PANTS_UPDATE_BUILD_FILES_FORMATTER
pants.toml
[update-build-files]
formatter = <Formatter>
one of: yapf, black, ruff, buildifier
default: black

Which formatter Pants should use to format BUILD files.

Advanced options

None

Deprecated options

None