Hi, I forked the Pants repo and added <ruff> inte...
# plugins
a
Hi, I forked the Pants repo and added ruff integration, I’m curious if this is something the Pants team would be interested in. I only have 1 failing unit test which checks the skip-ruff option, I couldn’t get it working yet. I would appreciate if anyone can help me with that. Here is the draft PR: https://github.com/pantsbuild/pants/pull/17945
💯 8
f
I enabled CI runs for the PR.
🙌 1
b
I very very very very much want ruff support in Pants, so yes. Please let us know how to help 😀
🚀 1
a
Thanks for the interest! You can see my comment for the failing test. I couldn’t get the
--ruff-skip
argument to work yet. I’ll take a look into it once I have more free time.
b
I'll take a look Monday. I'm sure it's something simple 😀
🙌 1
w
Do we still need to call
ruff.skip
in the main rules somewhere? Or is that handled by the infra now?
Err, check for
ruff.skip
b
That's usually handled by the opt-in partition rule, if you use that
w
Copy code
@rule(desc="Fix with ruff", level=LogLevel.DEBUG)
async def ruff_fix(request: RuffRequest.Batch, ruff: Ruff) -> FmtResult:
    ruff_pex_get = Get(
        VenvPex,
        PexRequest,
        ruff.to_pex_request(interpreter_constraints=request.partition_metadata),
    )
?
b
That's the runner rule, not the partitioner rule. By this point we know we're running the tool
w
Oops, missed the inheritence:
Copy code
class RuffRequest(FixTargetsRequest):
    field_set_type = RuffFieldSet
    tool_subsystem = Ruff
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION


@rule(desc="Fix with ruff", level=LogLevel.DEBUG)
async def ruff_fix(request: RuffRequest.Batch, ruff: Ruff) -> FmtResult:
    ruff_pex_get = Get(
        VenvPex,
        PexRequest,
        ruff.to_pex_request(interpreter_constraints=request.partition_metadata),
    )
So, does FixTargetsRequest handle the skip functionality?
b
The DEFAULT_SINGLE_PARTITION rule should, yes
👍 1
b
Thank you for contributing this @agreeable-microphone-98219!
🙌 1
For what it's worth, the maintainer of ruff is very active on twitter and seems keen to help community build on his work. Might be worth soliciting his thoughts on how to deal with the formatter vs fixer issue.
b
I think I did in a GitHub issue already. He was for it, but hasn't had to do any breaking changes and this would be one, so warrants more thinking
a
Thanks for approving the PR @bitter-ability-32190! Please lmk when we can merge this. I want to adopt this at the company I’m working for.
h
is this ready to merge? would love to see this in pants soon 👀
b
I got CI kicked
🚀 1
a
@bitter-ability-32190 Any idea how I can fix this CI error?
Copy code
Error: Unable to locate the previous sha: 5a200e8f404e72b8fcc7a74a444cb02d3c3d4c10
459
  Error: You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See <https://github.com/tj-actions/changed-files#usage>
460
  Error: Process completed with exit code 1.
b
Gotta pull latest
main
and merge into your branch
a
ok I'll rebase and push again
b
To save CI time we fetch up to some arbitrary depth. If you drift too far we can't fetch correctly.