Contextual diff lines checked
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
pycodestyle --diff is great! More programs should accept diffs as input.
Unfortunately it appears to consider lines in the diff that are merely context. Consider the following diff:
diff --git a/example.py b/example.py
index 955628d..b6c2b66 100644
--- a/example.py
+++ b/example.py
@@ -1,2 +1,5 @@
def invalid_but_irrelevant():
print("I am invalid but also irrelevant")
+
+def invalid_but_relevant():
+ print("I am invalid and relevant")
Line 2 (print("I am invalid but also irrelevant")) was not added in this diff, but pycodestyle still finds the problem with its indentation:
user@host:~/gists/98f18739ab30fb69d6154364dc1eee7a$ git diff HEAD~1 | pycodestyle --diff
./example.py:2:3: E111 indentation is not a multiple of four
./example.py:4:1: E302 expected 2 blank lines, found 1
./example.py:5:3: E111 indentation is not a multiple of four
I expect --diff to only consider lines added by a diff; otherwise code that's problematic but outside the scope of a change causes that change to fail linting checks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example by piping git diff HEAD~1 to pycodestyle --diff, then trace the --diff input handling in the repository's single Python file. Done means context lines such as example.py:2 are ignored while added lines still produce the expected errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100