cool-easter-32542
02/12/2024, 2:22 AMpants fmt :: makes many changes, and/or pants lint :: fails
Preferably Pants usually doesn't force people to make manual code changes for each upgrade (i.e. make it as easy as possible to stay up to date). To land an upgrade to 2.20, I'd have to go and either disable black/isort and use ruff, or somehow disable ruff's formatting while retaining its linting (which doesn't seem to be possible in pants).
Reproducer:
cd $(mktemp -d)
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.19.0"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.black",
"pants.backend.experimental.python.lint.ruff",
]
[python]
interpreter_constraints = ["CPython==3.10.*"]
EOF
echo 'python_sources(name="foo")' > BUILD
# <https://docs.astral.sh/ruff/formatter/black/#single-element-tuples-are-always-parenthesized>
echo '(1, 2),' > foo.py
# OK: everything passes with 2.19.0
pants lint ::
# BUG: ruff now tries reformatting, and has changes the syntax
PANTS_VERSION=2.20.0.dev0 pants lint ::
The first pants lint :: run (OK) demonstrates that the code passes, while the second does the "upgrade" to the first release with #20098, demonstrating that ruff formatter now runs, but fails.
That (ab)uses one of the differences between the ruff and black formatters that doesn't matter in the real world, but the same applies if black has configuration that isn't (yet) configured for ruff, e.g. if we had configured a longer line length, ruff might try squishing any lines that exceed its default (88?).
# pyproject.toml
[tool.black]
line-length = 120
In #20510 (comment) and onwards, we discuss some options.
Pants version
2.20.0.dev7
OS
macOS
Additional info
N/A
pantsbuild/pantscool-easter-32542
02/16/2024, 7:59 AM