Skip to main content
Version: 2.23 (prerelease)

migrate-call-by-name


pants migrate-call-by-name [args]

Migrate from Get syntax to call-by-name syntax (#19730). This is a destructive operation, so only run this on source controlled files that you are prepared to revert if necessary.

This goal will attempt to migrate the set of paths/targets specified at the command line if they are part of the "migration plan". This migration does not add any new files, but instead modifies existing files in-place without any formatting. The resulting changes should be reviewed, tested, and formatted/linted before committing.

The migration plan is a JSON representation of the rule graph, which is generated by the engine based on the active backends/rules in the project.

Each item in the migration plan is a rule that contains the old Get syntax, the associated input/output types, and the new function to directly call. The migration plan can be dumped as JSON using the --json flag, which can be useful for debugging. For example:

{ "filepath": "src/python/pants/source/source_root.py", "function": "get_source_roots", "gets": [{ "input_types": [{ "module": "pants.source.source_root", "name": "SourceRootsRequest" }], "output_type": { "module": "pants.source.source_root", "name": "OptionalSourceRootsResult" }, "rule_dep": { "function": "get_optional_source_roots", "module": "pants.source.source_root" } }], "module": "pants.source.source_root" }

Backend: pants.goal

Config section: [migrate-call-by-name]

Basic options

json

--[no-]migrate-call-by-name-json
PANTS_MIGRATE_CALL_BY_NAME_JSON
pants.toml
[migrate-call-by-name]
json = <bool>
default: False

Dump the migration plan as JSON

Advanced options

None

Deprecated options

None

None