Contextual diff lines checked
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
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.
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.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 765
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from PyCQA/pycodestyle
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
PyCQA/pycodestyle#1294 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
PyCQA/pycodestyle#1302 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
PyCQA/pycodestyle#1242 · 2 comments ·
-
Spurious E231 for nested format substitutionsMay be free again @inchang-ing claimed this 34 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
PyCQA/pycodestyle#1241 · 3 comments · 4 reactions ·
-
`exclude` is applied to `.`May be free again @OnlineBunker claimed this 12 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
PyCQA/pycodestyle#1217 · 3 comments ·
All issues in PyCQA/pycodestyle
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Library sweep logs an ERROR at start for the valkey instrumentor when valkey-py is not installedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
JoahanMorales/upiixia-agentic-kit#99 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100