How can I run a formatting check in the CI? I need...
# general
f
How can I run a formatting check in the CI? I need a command that exits !=0 in case reformatting was necessary. There is the
lint
target, however this also runs all linters and I cannot distinguish whether any !=0 exit code stems from a linter or a formatter.
c
Have you looked at permutations with
--[no-]lint-skip-formatters
? https://www.pantsbuild.org/2.18/reference/goals/lint
f
Yes, but the available settings don't do what I need. There is
skip_fixers
and
skip_formatters
but I need
skip_linters
. It might sound confusing to run
pants lint --lint-skip-linters
but as
lint
runs linters as well as formatters/fixers this would make sense to me. Or is that possible and I overlooked something?
c
I think you could do
--lint-only=[]
, albeit while manually making this list
f
I just discovered that pants
2.20.0rc0
now splits ruff into 2 lint parts:
ruff-check
and
ruff-format
. Together with your advice
lint-only
I can achieve my goal:
pants lint --lint-only="['ruff-format']" <target>
Thanks!
fwiw, this also works
pants lint --only="['ruff-format']" <target>