cool-easter-32542
09/21/2023, 7:12 AMpants fmt lint :: fail spuriously in the lint step, due to the formatters that were just run. Rerunning immediately passes.
We're generally editing Python so we usually see this with black, but I imagine it's not black-specific.
Reproducer:
# run.sh
cd $(mktemp -d)
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.17.0"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.black",
]
[python]
interpreter_constraints = ["==3.9.*"]
EOF
echo 'python_sources(name="x")' > BUILD
echo 'a = 1' > file.py
# BUG: lint run fails
pants --no-pantsd --no-local-cache fmt lint ::
# OK: rerunning works fine
pants --no-pantsd --no-local-cache lint ::
Running this like PANTS_VERSION=2.16.0 bash run.sh (or whatever version) shows two sets of pants output: first, the `BUG`:
17:07:24.54 [WARN] Completed: Format with Black - black made changes.
file.py
+ black made changes.
ā black failed.
(One or more formatters failed. Run `pants fmt` to fix.)
Then the `OK`:
17:07:35.46 [INFO] Completed: Format with Black - black made no changes.
ā black succeeded.
Pants version
2.16.0, 2.19.0.dev0
Doesn't reproduce on 2.15.0
scie-pants version 0.10.1
OS
macOS
Additional info
Trimmed output of the failure:
17:10:39.16 [DEBUG] Running Run Black on 1 file. under semaphore with concurrency id: 5, and concurrency: 1
17:10:39.16 [DEBUG] Starting: Run Black on 1 file.
17:10:39.16 [DEBUG] Starting: setup_sandbox
17:10:39.17 [DEBUG] Completed: setup_sandbox
17:10:39.17 [DEBUG] Obtaining exclusive spawn lock for process since we materialized its executable Some("./black.pex_pex_shim.sh").
17:10:39.17 [DEBUG] spawned local process as Some(35087) for Process { argv: ["./black.pex_pex_shim.sh", "-W", "1", "file.py"], env: {}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<01f1bfd1b9af4fae820f807ce0f32d1cde217617d081de5eb12e7d87dcb6a66f>, size_bytes: 464 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, input_files: DirectoryDigest { digest: Digest { hash: Fingerprint<4ddb53f65c1859b96b165b5530b3c2d3630c5d4399f3175d163e713f0e39b3a0>, size_bytes: 368 }, tree: "Some(..)" }, immutable_inputs: {RelativePath(".python-build-standalone"): DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }}, use_nailgun: {} }, output_files: {RelativePath("file.py")}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 1, description: "Run Black on 1 file.", level: Debug, append_only_caches: {CacheName("pex_root"): RelativePath(".cache/pex_root")}, jdk_home: None, cache_scope: Successful, execution_environment: ProcessExecutionEnvironment { name: None, platform: Macos_arm64, strategy: Local }, remote_cache_speculation_delay: 0ns }
17:10:39.27 [DEBUG] Completed: Run Black on 1 file.
17:10:39.27 [DEBUG] Completed: Scheduling: Run Black on 1 file.
17:10:39.27 [DEBUG] Output from black
reformatted file.py
All done! ⨠š° āØ
1 file reformatted.
17:10:39.27 [WARN] Completed: Format with Black - black made changes.
file.py
+ black made changes.
17:10:39.27 [DEBUG] Completed: `fmt` goal
17:10:39.27 [DEBUG] computed 1 nodes in 2.472489 seconds. there are 159 total nodes.
17:10:39.27 [DEBUG] requesting <class 'pants.core.goals.lint.Lint'> to satisfy execution of `lint` goal
17:10:39.27 [DEBUG] Launching 1 roots (poll=false).
17:10:39.27 [DEBUG] Starting: `lint` goal
17:10:39.27 [DEBUG] Starting: Find all sources from input specs
17:10:39.27 [DEBUG] Completed: Find all sources from input specs
17:10:39.27 [DEBUG] Starting: pants.core.goals.fix.convert_fix_result_to_lint_result
ā black failed.
(One or more formatters failed. Run `pants fmt` to fix.)
pantsbuild/pantscool-easter-32542
09/27/2023, 11:49 PM