flake8-diff-only 0.1.4__py3-none-any.whl → 0.1.5__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.
- flake8_diff_only/__init__.py +1 -1
- flake8_diff_only/checker.py +2 -2
- flake8_diff_only/patch.py +22 -22
- flake8_diff_only/types.py +1 -1
- flake8_diff_only/utils.py +40 -40
- {flake8_diff_only-0.1.4.dist-info → flake8_diff_only-0.1.5.dist-info}/METADATA +1 -1
- flake8_diff_only-0.1.5.dist-info/RECORD +10 -0
- flake8_diff_only-0.1.4.dist-info/RECORD +0 -10
- {flake8_diff_only-0.1.4.dist-info → flake8_diff_only-0.1.5.dist-info}/LICENSE.md +0 -0
- {flake8_diff_only-0.1.4.dist-info → flake8_diff_only-0.1.5.dist-info}/WHEEL +0 -0
- {flake8_diff_only-0.1.4.dist-info → flake8_diff_only-0.1.5.dist-info}/entry_points.txt +0 -0
flake8_diff_only/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
from flake8_diff_only import patch # noqa: F401
|
1
|
+
from flake8_diff_only import patch # noqa: F401
|
flake8_diff_only/checker.py
CHANGED
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
|
@@ -0,0 +1,10 @@
|
|
1
|
+
flake8_diff_only/__init__.py,sha256=N2YaaHCkBqW6hN3QQwL-mqQhhlC2eBqqXcO7n2-m9zQ,50
|
2
|
+
flake8_diff_only/checker.py,sha256=fRQQpFROW4BfCtVC_pwFQJZp3ZsEuU_ekvceLrAmhIk,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.5.dist-info/LICENSE.md,sha256=sBI8-TYatRBlqWblXpDP6vKYkA2tKMdxstXkz999qJU,1060
|
7
|
+
flake8_diff_only-0.1.5.dist-info/METADATA,sha256=nr7nTN7FkMOMQUndWZYb1vBLtoyNulnHQIiJATmNTsY,1518
|
8
|
+
flake8_diff_only-0.1.5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
9
|
+
flake8_diff_only-0.1.5.dist-info/entry_points.txt,sha256=CXw_iI0JlWvRjMglpKBJ04ooVA2r_mSA4cMi9QxV3Ts,71
|
10
|
+
flake8_diff_only-0.1.5.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,,
|
File without changes
|
File without changes
|
File without changes
|