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

ENH: incremental changes to modify only code neighboring already changed lines #370

Closed
mattip opened this issue Jun 21, 2018 · 3 comments
Closed

Comments

@mattip
Copy link

mattip commented Jun 21, 2018

Idea: allow running black with a -n --dry-run=filename option and store the resulting changeset. Then allow using this in a subsequent run to only update newly found changes.

Rational: In a workflow on an established managed repository, this would allow running black incrementally, reformatting only parts of the code that have been changed, minimizing git churn and blame lines.

@ambv
Copy link
Collaborator

ambv commented Jun 21, 2018

This is something we explicitly don't support. Incremental style changes are against PEP 8's philosophy of staying consistent within a file. They also mix formatting changes with semantic changes, making review harder than it needs to be. See #134 for a longer explanation.

Reformat your entire project in one go. Then there is a single commit that is trivial to omit using git hyper-blame or simply by using git blame $BLACK_COMMIT^ -- $FILE. It's a cleaner approach than trying to smear adoption over time.

See also: #320

@ambv ambv closed this as completed Jun 21, 2018
@wbolster
Copy link
Contributor

wbolster commented Feb 6, 2019

fyi, i wrote https://github.com/wbolster/black-macchiato

@akaihola
Copy link

Also FYI, I wrote darker for applying Black formatting only to lines which have changed in the Git working tree since the last commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants