flake8-diff-only 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- from flake8_diff_only import patch # noqa: F401
1
+ from flake8_diff_only import patch # noqa: F401
@@ -3,10 +3,10 @@ import ast
3
3
 
4
4
  class Flake8DiffOnlyChecker:
5
5
  name = "flake8-diff-only"
6
- version = "0.1.4"
6
+ version = "0.1.6"
7
7
 
8
8
  def __init__(self, tree: ast.AST, filename: str):
9
9
  pass
10
10
 
11
11
  def run(self): # type: ignore[no-untyped-def]
12
- pass
12
+ return []
flake8_diff_only/patch.py CHANGED
@@ -1,22 +1,22 @@
1
- import flake8.checker
2
-
3
- from flake8_diff_only.utils import get_changed_lines
4
-
5
- _original_run_checks = flake8.checker.FileChecker.run_checks
6
-
7
-
8
- def _patched_run_checks(self) -> tuple[str, list, list] | None: # type: ignore
9
- if not hasattr(self, "_changed_lines"):
10
- self._changed_lines = get_changed_lines(self.filename)
11
-
12
- results = _original_run_checks(self)
13
- if results is None or not self._changed_lines:
14
- return None
15
-
16
- self.filename, self.results, self.statistics = results
17
- self.results = list(filter(lambda r: r[1] in self._changed_lines, self.results))
18
-
19
- return self.filename, self.results, self.statistics
20
-
21
-
22
- flake8.checker.FileChecker.run_checks = _patched_run_checks
1
+ import flake8.checker
2
+
3
+ from flake8_diff_only.utils import get_changed_lines
4
+
5
+ _original_run_checks = flake8.checker.FileChecker.run_checks
6
+
7
+
8
+ def _patched_run_checks(self) -> tuple[str, list, list] | None: # type: ignore
9
+ if not hasattr(self, "_changed_lines"):
10
+ self._changed_lines = get_changed_lines(self.filename)
11
+
12
+ results = _original_run_checks(self)
13
+ if results is None or not self._changed_lines:
14
+ return None
15
+
16
+ self.filename, self.results, self.statistics = results
17
+ self.results = list(filter(lambda r: r[1] in self._changed_lines, self.results))
18
+
19
+ return self.filename, self.results, self.statistics
20
+
21
+
22
+ flake8.checker.FileChecker.run_checks = _patched_run_checks
flake8_diff_only/types.py CHANGED
@@ -1 +1 @@
1
- LineNumber = int
1
+ LineNumber = int
flake8_diff_only/utils.py CHANGED
@@ -1,40 +1,40 @@
1
- import subprocess
2
-
3
- from flake8_diff_only.types import LineNumber
4
-
5
-
6
- def get_changed_lines(filename: str) -> set[LineNumber]:
7
- """
8
- Получаем множество изменённых строк из git diff.
9
- """
10
- changed_lines: set[LineNumber] = set()
11
-
12
- diff_cmd = ["git", "diff", "--unified=0", "--no-color", "--cached", filename]
13
- try:
14
- output = subprocess.check_output(diff_cmd, stderr=subprocess.DEVNULL).decode()
15
- except subprocess.CalledProcessError:
16
- return changed_lines
17
-
18
- for line in output.splitlines():
19
- if line.startswith("@@"):
20
- # Парсим хедер ханка: @@ -old,+new @@
21
- try:
22
- new_section = line.split(" ")[2]
23
- start_line, length = _parse_diff_range(new_section)
24
- lines = set(range(start_line, start_line + length))
25
- changed_lines.update(lines)
26
- except Exception:
27
- continue
28
- return changed_lines
29
-
30
-
31
- def _parse_diff_range(range_str: str) -> tuple[LineNumber, int]:
32
- """
33
- Парсит формат вроде '+12,3' или '+45' → (start_line, length)
34
- """
35
- range_str = range_str.lstrip("+")
36
- if "," in range_str:
37
- start, length = map(int, range_str.split(","))
38
- else:
39
- start, length = int(range_str), 1
40
- return start, length
1
+ import subprocess
2
+
3
+ from flake8_diff_only.types import LineNumber
4
+
5
+
6
+ def get_changed_lines(filename: str) -> set[LineNumber]:
7
+ """
8
+ Получаем множество изменённых строк из git diff.
9
+ """
10
+ changed_lines: set[LineNumber] = set()
11
+
12
+ diff_cmd = ["git", "diff", "--unified=0", "--no-color", "--cached", filename]
13
+ try:
14
+ output = subprocess.check_output(diff_cmd, stderr=subprocess.DEVNULL).decode()
15
+ except subprocess.CalledProcessError:
16
+ return changed_lines
17
+
18
+ for line in output.splitlines():
19
+ if line.startswith("@@"):
20
+ # Парсим хедер ханка: @@ -old,+new @@
21
+ try:
22
+ new_section = line.split(" ")[2]
23
+ start_line, length = _parse_diff_range(new_section)
24
+ lines = set(range(start_line, start_line + length))
25
+ changed_lines.update(lines)
26
+ except Exception:
27
+ continue
28
+ return changed_lines
29
+
30
+
31
+ def _parse_diff_range(range_str: str) -> tuple[LineNumber, int]:
32
+ """
33
+ Парсит формат вроде '+12,3' или '+45' → (start_line, length)
34
+ """
35
+ range_str = range_str.lstrip("+")
36
+ if "," in range_str:
37
+ start, length = map(int, range_str.split(","))
38
+ else:
39
+ start, length = int(range_str), 1
40
+ return start, length
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: flake8-diff-only
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Flake8 plugin to show errors only on changed lines
5
5
  License: MIT
6
6
  Keywords: flake8,plugin,quotes,code quality
@@ -30,11 +30,22 @@ Description-Content-Type: text/markdown
30
30
  # Project: flake8-diff-only
31
31
 
32
32
  ## Description
33
- This project provides a plugin for Flake8 that checks only the modified lines of files for Flake8 violations.
33
+
34
+ This project provides a plugin for **Flake8** that checks only the modified lines of files for style violations.
35
+
36
+ > ⚠️ **Please note:**
37
+ >
38
+ > * The [current implementation of `--diff` is fundamentally flawed by design](https://github.com/pycqa/flake8/issues/1389).
39
+ > * The [`--diff` option was deprecated in Flake8 5.0.0](https://flake8.pycqa.org/en/latest/release-notes/5.0.0.html#deprecations).
40
+ > * The [`--diff` option was removed entirely in Flake8 6.0.0](https://flake8.pycqa.org/en/latest/release-notes/6.0.0.html#backwards-incompatible-changes).
41
+
42
+ This project replicates that deprecated functionality but as a plugin, and naturally inherits the same limitations.
43
+ However, it has distinct advantages — particularly in **legacy codebases**, where running full Flake8 checks may produce excessive noise.
44
+ That's why I decided to recreate this feature in the form of a plugin.
34
45
 
35
46
  ## Usage
36
47
 
37
- To install the plugin, use the following command:
48
+ To install the plugin, run:
38
49
 
39
50
  ```bash
40
51
  pip install flake8-diff-only
@@ -0,0 +1,10 @@
1
+ flake8_diff_only/__init__.py,sha256=N2YaaHCkBqW6hN3QQwL-mqQhhlC2eBqqXcO7n2-m9zQ,50
2
+ flake8_diff_only/checker.py,sha256=eoUWPZfFbVbth-YZ3flfkku5FwYNJAEOe7cmPHZProE,232
3
+ flake8_diff_only/patch.py,sha256=flBa-UO1cBGutLyiUKBHefhXepoeJyD2JoVLY2_Nc9A,726
4
+ flake8_diff_only/types.py,sha256=W-3mb7tKFaZToRHeQZjafUIZhhAUYdr6D8aJE7siIpQ,18
5
+ flake8_diff_only/utils.py,sha256=yPeTUi2LVYHbwUeaFIuk87ymNhC553Cfr-m0GEPxS1U,1389
6
+ flake8_diff_only-0.1.6.dist-info/LICENSE.md,sha256=sBI8-TYatRBlqWblXpDP6vKYkA2tKMdxstXkz999qJU,1060
7
+ flake8_diff_only-0.1.6.dist-info/METADATA,sha256=RFSbA077ac9EL19P5Ty5wZbDWQbgBrGFIWyvwgAN4n4,2270
8
+ flake8_diff_only-0.1.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
9
+ flake8_diff_only-0.1.6.dist-info/entry_points.txt,sha256=CXw_iI0JlWvRjMglpKBJ04ooVA2r_mSA4cMi9QxV3Ts,71
10
+ flake8_diff_only-0.1.6.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- flake8_diff_only/__init__.py,sha256=mY8HBYGvPU1W5pMYGPcYWFUvslzDwVNUVe4CI38eMxg,49
2
- flake8_diff_only/checker.py,sha256=wtu1MQQXdbaseRSDKWdKcQEQ2aTFrJHxEbRUP2hYZPk,227
3
- flake8_diff_only/patch.py,sha256=uQ2BA6pbxFK9pve_IxSeYCmHcmk5IskbxGvCZeB92l0,704
4
- flake8_diff_only/types.py,sha256=zmwrvxKU9fP21rdQMkGnPELmTxEh2QNXxDPQ8JjI4bU,17
5
- flake8_diff_only/utils.py,sha256=M55e_tIqjN0_BT0NjY9C8RF92FOol2SMQuiV1l2D0Bg,1349
6
- flake8_diff_only-0.1.4.dist-info/LICENSE.md,sha256=sBI8-TYatRBlqWblXpDP6vKYkA2tKMdxstXkz999qJU,1060
7
- flake8_diff_only-0.1.4.dist-info/METADATA,sha256=a3joHa7F0QJWW_k7q435q0dzQG2vbuGXqZupLSolKYw,1518
8
- flake8_diff_only-0.1.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
9
- flake8_diff_only-0.1.4.dist-info/entry_points.txt,sha256=CXw_iI0JlWvRjMglpKBJ04ooVA2r_mSA4cMi9QxV3Ts,71
10
- flake8_diff_only-0.1.4.dist-info/RECORD,,