Instagram / Fixit

Advanced Python linting framework with auto-fixes and hierarchical configuration that makes it easy to write custom in-repo lint rules.
https://fixit.rtfd.io/en/latest/
Other
659 stars 62 forks source link

make format of fixit's terminal output configurable #437

Closed jvllmr closed 5 days ago

jvllmr commented 3 months ago

Summary

This PR makes the format of Fixit's output configurable. I hope I got everything right ๐Ÿ˜ธ

fixes #397 closes #305

facebook-github-bot commented 3 months ago

Hi @jvllmr!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

facebook-github-bot commented 3 months ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

amyreese commented 3 months ago

First off, I greatly appreciate the PR, thank you! That said, I have some concerns with the current design.

I'm not fond of passing the original config object back for every single result, for a few reasons:

Instead, I think what would make most sense is to pull the config for the current working directory in the CLI module, and then pass the relevant output format straight to print_result. This would ensure a consistent formatting style for the run based on where Fixit is run from. This would also make it relatively trivial to implement --output-format and use that instead of the config when given.


On the actual config mechanism, I think rather than enabling this as a free-form text field (which I suspect would be overly complicated for 99% of use cases), a set of "named" formats would be better. Eg, output-format = "vscode" provides clear intent, and is likely less error-prone than copy-pasting a bunch of raw format strings.

A standardized JSON result could be defined with output-format = "json", and the proposed free-form behavior could then be implemented as something like output-format = "custom" and output-format-template = "...", or maybe just `output-format = "template: