-
Notifications
You must be signed in to change notification settings - Fork 65
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
feat: support linting stdin #388
Conversation
Hi @llllvvuu! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
CLA submitted |
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 like this as functionality to support, but I'd rather push this functionality into the supported API, rather than handling stdin at the CLI layer.
Take a look at how we did this for µfmt, where passing Path("-")
(what you get from click.Path(allow_dash=True) as the first element of paths
to ufmt_paths(...)
triggers handling for stdin. https://github.com/omnilib/ufmt/blob/main/ufmt/core.py#L308
Adding fixit_stdin
to the API to handle reading stdin and wrap fixit_bytes
would be the first step, then update fixit_paths
to detect the stdin sentinel and defer to fixit_stdin
instead of normal file processing.
Is that something you would be interested in tackling, or would you rather I adapt your work accordingly?
Just took a look at ufmt CLI and happy to make the changes. So to confirm, intended usage is fixit lint - path/to/foo.py # formats stdin, treating it as if it is located at path/to/foo.py |
Correct :) |
cat foo.py | fixit lint --stdin --stdin-filepath foo.py
1b01d2f
to
449c805
Compare
Just made the changes, thanks again for the ufmt reference! I wasn't able to leave |
85ea7ae
to
d42fa15
Compare
Similarly for `fixit fix`
Thank you! |
Similarly for
fixit fix
. The API is inspired by Prettier.Summary
Related to #122 but does not fully resolve it. It supports a lint-as-you-type workflow, whereas only a lint-on-save workflow could be supported before. Full resolution of #122 would require #387.
Test Plan
Extended smoke tests.