New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Taplo toml formatter #18865
Add Taplo toml formatter #18865
Conversation
Can you link the thread that talked about why we need this as a target formatter? I don't see anything specific to targets other than skip. |
@thejcannon I just edited the OP with the thread. The main thing is that if I have a |
So with targetless formatters/fixers they simply work on globs. They also don't not work on files-that-have-targets (double negative). Case and point is So check out |
Thanks @thejcannon! Would there be a way to exclude certain files from formatting then? Just by the glob? |
Yup, glob-based excludes (you could use one glob for everything, or separate includes/excludes globs). Kinda nasty but that's the art. |
OK great, thanks! I'll look at the |
Oh yes, we love upstreamed plugins. I for one welcome more and more formatters. Please do continue this PR 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm super stoked for this, thank you for your contribution and your patience!
🚀
@rule | ||
async def partition_inputs( | ||
request: TaploFmtRequest.PartitionRequest, taplo: Taplo | ||
) -> Partitions[Any]: | ||
if taplo.skip: | ||
return Partitions() | ||
|
||
print(taplo) | ||
return Partitions.single_partition(taplo.filter_inputs(request.files)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should file myself an issue to make this less boilerplate-y.
Get tests passing. Add a test for globs working properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Minor comments then we can merge.
Thanks again! (And don't forget, open invitation to do the honors of turning this on in this repo 🏆 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go ahead and merge the nits.
Thanks a million!
Hmm CI seems to be on vacation. Can you merge latest |
Per the thread here: https://pantsbuild.slack.com/archives/C0D7TNJHL/p1685984488435849?thread_ts=1685983060.055239&cid=C0D7TNJHL after merging the Taplo formatter with #18865 it wasn't added to the release dependencies. This adds the backend to the file.
Per the thread here: https://pantsbuild.slack.com/archives/C0D7TNJHL/p1685984488435849?thread_ts=1685983060.055239&cid=C0D7TNJHL after merging the Taplo formatter with #18865 it wasn't added to the release dependencies. This adds the backend to the file.
Per the thread here: https://pantsbuild.slack.com/archives/C0D7TNJHL/p1685984488435849?thread_ts=1685983060.055239&cid=C0D7TNJHL after merging the Taplo formatter with #18865 it wasn't added to the release dependencies. This adds the backend to the file. Co-authored-by: Bryan Weber <bweber@rebelliondefense.com>
This PR adds Taplo as a downloaded tool to format TOML files. As currently implemented, there are two rules, one for
toml_sources
and one specifically forpyproject.toml
files. @thejcannon suggested making a PR to talk about a targetless/hybrid formatter for TOML files.I can't dig up the Slack thread at the moment but I'll add it when I can!Slack thread: https://pantsbuild.slack.com/archives/C046T6T9U/p1680552392695329