question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yapf-diff (similar to clang-format-diff) ?

See original GitHub issue

I am using clang-format a lot. And it’s very convenient to do so via clang-format-diff script (quick description from https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py):

ClangFormat Diff Reformatter
============================

This script reads input from a unified diff and reformats all the changed
lines. This is useful to reformat all the lines touched by a specific patch.
Example usage for git/svn users:

  git diff -U0 HEAD^ | clang-format-diff.py -p1 -i
  svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i

It would great to have similar script for yapf. Looks like currently yapf doesn’t have this mode available.

Do you have plans on supporting this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
mwekcommented, Mar 9, 2017

I modified the clang-format-diff.py to work with yapf and Python 3: https://gist.github.com/mwek/59aefeefc812dea39c93c068eb30b491

Feel free to add this to the repo.

0reactions
SKaltcommented, Nov 8, 2020

The above now has an apache-2 licence.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code style conventions - Psi4
It is important to keep a consistent formatting of the C++ and Python code to avoid hard-to-read diffs and merge conflicts. clang-format and...
Read more >
README.rst - platform/external/yapf - android Git repositories
YAPF takes a different approach. It's based off of 'clang-format', developed by. Daniel Jasper. ... The idea is also similar to the 'gofmt'...
Read more >
Open3D style guide — Open3D 0.13.0 documentation
Open3D's CI checks for code formatting based on the style specified in .clang-format for C++ files and .style.yapf for Python files. Please build...
Read more >
yapf · PyPI
YAPF takes a different approach. It's based off of 'clang-format', developed by Daniel Jasper. In essence, the algorithm takes the code and reformats...
Read more >
File: productivity.md | Debian Sources
To get the most out of ccache, put something like this in `~/.ccache/ccache.conf`: ... Format Python diffs with `yapf-diff.py` Usage is exactly the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found