Skip to content
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

RFE: --diff and --recursive #59

Closed
pradyunsg opened this issue Nov 10, 2018 · 8 comments
Closed

RFE: --diff and --recursive #59

pradyunsg opened this issue Nov 10, 2018 · 8 comments

Comments

@pradyunsg
Copy link

pradyunsg commented Nov 10, 2018

I think the following would be some good enhancements to this tool:

  • --diff like isort, which prints the suggested changes on stdout, instead of modifying the files.

    This is great for CI checks where a contributor gets to see the required changes to fix the situation directly.

  • --recursive option, to specify an entire project directory without globs.

    This would make CLI invocations easier.

I'll be happy to write PRs for them if @asottile thinks they're reasonable.

@asottile
Copy link
Owner

The intention is to run the tool through pre-commit which means every tool in the world doesn't have to reimplement:

  • file matching (complicated, involves exclusion / inclusion / recursion / etc.)
  • dry run / diff / etc.

I don't have an interest in supporting these complicated options in each and every tool, pre-commit run --all-files does a much better job than any tool could since it only will run against git tracked files (and the hook metadata configures what is included vs excluded). pre-commit run --all-files --show-diff-on-failure is the intended CI tool as well, which (as you'd expect) shows a diff.

See also:

@pradyunsg
Copy link
Author

Fair enough. :)

@suntzu86
Copy link

TIL --show-diff-on-failure. Sweet!

@sobolevn
Copy link

You can always use find:

find . -name '*.py' -not -path "./.venv/*" -exec add-trailing-comma --py36-plus {} +

@rugleb
Copy link

rugleb commented Oct 14, 2020

You can always use find:

find . -name '*.py' -not -path "./.venv/*" -exec add-trailing-comma --py36-plus {} +

But what about Windows? For example, I have 2 folders: project and tests.
In Linux i use find:

add-trailing-comma $(shell find project tests -name "*.py") --exit-zero-even-if-changed --py36-plus

and it's good.
But how it should work in Windows?

I'm sure that the recursive option is required

@asottile
Copy link
Owner

on windows you necessarily have both python, bash, and coreutils for git so there's plenty of options there

@rugleb
Copy link

rugleb commented Oct 14, 2020

My colleagues and I use the same repository, the same environment, and the same Makefile that describes all the commands for the convenience of running help utilities (tests, linters, formatters). Someone uses Linux, and someone uses Windows. I am sure that many people do exactly the same. In the absence of support for recursion formatting, you have to build large crutches or, in some cases, abandon the tool. Therefore, the function would be extremely useful.

@asottile
Copy link
Owner

no: #59 (comment)

Repository owner locked and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants