Skip to content

Commit 61b483c

Browse files
caishilongclaude
andcommitted
fix: 修复测试和示例代码中的 ruff 错误
## 问题修复 - 移除未使用的导入 - 修复 f-string 没有占位符的问题 - 添加 noqa 注释处理 E402(sys.path 修改后的导入) ## 修改文件 - test/test_supervision.py: 移除未使用导入,添加 noqa - test/simple_test.py: 修复 f-string 和导入 - examples/quick_demo.py: 移除未使用导入,添加 noqa Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bf5f093 commit 61b483c

3 files changed

Lines changed: 17 additions & 28 deletions

File tree

examples/quick_demo.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""Supervision SDK 使用示例"""
2+
"""svision SDK 使用示例"""
33

44
import sys
55
from pathlib import Path
@@ -9,29 +9,22 @@
99
project_root = Path(__file__).resolve().parent.parent
1010
sys.path.insert(0, str(project_root))
1111

12-
from svision import find_location, find_text_position, recognize_text
13-
from svision.options import Options
12+
from svision import find_location, find_text_position, recognize_text # noqa: E402
1413

1514

1615
def main():
17-
# OCR 配置(按需)
18-
# Options.OCR_LANGUAGE = "ch"
19-
# Options.OCR_USE_GPU = True
20-
# Options.OCR_DEVICE = "gpu:0"
21-
# Options.OCR_USE_ANGLE_CLS = False
22-
2316
target_image = cv2.imread("test/assets/target.png")
2417
if target_image is None:
2518
raise RuntimeError("无法读取目标图像")
2619

2720
# 模板匹配
28-
pos = find_location(target_image, "test/assets/template1.png", threshold=0.8)
21+
find_location(target_image, "test/assets/template1.png", threshold=0.8)
2922

3023
# OCR 全量识别
31-
texts = recognize_text(target_image)
24+
recognize_text(target_image)
3225

3326
# 查找指定文本位置
34-
text_pos = find_text_position(target_image, "控制台")
27+
find_text_position(target_image, "控制台")
3528

3629

3730
if __name__ == "__main__":

test/simple_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
sys.path.insert(0, str(project_root))
1212

1313
print("=" * 60)
14-
print("📦 Supervision 项目测试")
14+
print("📦 svision 项目测试")
1515
print("=" * 60)
1616
print()
1717

@@ -31,7 +31,7 @@
3131

3232
try:
3333
from PIL import Image
34-
print(f" ✅ PIL")
34+
print(" ✅ PIL")
3535
except ImportError as e:
3636
print(f" ❌ PIL: {e}")
3737

@@ -40,21 +40,21 @@
4040

4141
try:
4242
from svision.options import Options
43-
print(f" ✅ supervision.options")
43+
print(" ✅ svision.options")
4444
except ImportError as e:
45-
print(f" ❌ supervision.options: {e}")
45+
print(f" ❌ svision.options: {e}")
4646

4747
try:
4848
from svision.aircv import aircv as aircv_module
49-
print(f" ✅ supervision.aircv")
49+
print(" ✅ svision.aircv")
5050
except ImportError as e:
51-
print(f" ❌ supervision.aircv: {e}")
51+
print(f" ❌ svision.aircv: {e}")
5252

5353
try:
5454
from svision.orc import TextRecognizer
55-
print(f" ✅ supervision.orc")
55+
print(" ✅ svision.orc")
5656
except ImportError as e:
57-
print(f" ❌ supervision.orc: {e}")
57+
print(f" ❌ svision.orc: {e}")
5858

5959
print()
6060
print("✓ 测试 3: 检查测试资源")
@@ -64,7 +64,7 @@
6464
files = list(test_assets.glob("*.png"))
6565
print(f" ✅ 测试资源目录存在 ({len(files)} 个图像文件)")
6666
else:
67-
print(f" ❌ 测试资源目录不存在")
67+
print(" ❌ 测试资源目录不存在")
6868

6969
print()
7070
print("=" * 60)

test/test_supervision.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@
1818
project_root = Path(__file__).parent.parent
1919
sys.path.insert(0, str(project_root))
2020

21-
from svision import (
21+
from svision import ( # noqa: E402
2222
find_location,
23-
find_all_locations,
2423
recognize_text,
25-
find_text_position,
2624
)
27-
from svision.orc import TextRecognizer, clear_ocr_cache
28-
from svision.options import Options
29-
from svision.utils import logger
30-
import logging
25+
from svision.utils import logger # noqa: E402
26+
import logging # noqa: E402
3127

3228

3329
class TestConfig:

0 commit comments

Comments
 (0)