Skip to content

Commit 2ce9f3f

Browse files
authored
feat: Add CI for Ruff checking (#2)
* fix: Fix error in pyproject.toml * chores: Format with ruff * refactor: Mute lint error for unfinished sdk * chore: update Ruff workflow * feat: Apply settings
1 parent 64e67d0 commit 2ce9f3f

File tree

10 files changed

+691
-540
lines changed

10 files changed

+691
-540
lines changed

.github/workflows/ruff.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Ruff
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
pull_request:
7+
types: [opened, synchronize, reopened, ready_for_review]
8+
9+
jobs:
10+
lint:
11+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Install Ruff
23+
run: pip install ruff
24+
25+
- name: Format code
26+
run: ruff --config pyproject.toml format .
27+
28+
- name: Fix lint issues
29+
run: ruff --config pyproject.toml check --fix --exit-zero .
30+
31+
- name: Ensure no remaining lint issues
32+
run: ruff --config pyproject.toml check .

netpulse-client/examples/sdk_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import asyncio
2-
from netpulse_client import NetPulseClient, Device
1+
from netpulse_client import Device, NetPulseClient
32

43
# 配置信息
54
ENDPOINT = "http://localhost:9000"
@@ -19,7 +18,7 @@
1918

2019
def basic_operations():
2120
print("=== 基础操作示例 ===")
22-
21+
2322
with NetPulseClient(ENDPOINT, API_KEY) as np_client:
2423
# 1. 执行命令
2524
print("\n1. 执行命令")
@@ -35,6 +34,5 @@ def basic_operations():
3534
print(result.request_id)
3635

3736

38-
3937
if __name__ == "__main__":
40-
basic_operations()
38+
basic_operations()
Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""
22
NetPulse Client - 网络设备自动化客户端
33
4-
提供同步和异步的网络设备操作接口支持命令执行和配置推送。
4+
提供同步和异步的网络设备操作接口, 支持命令执行和配置推送。
55
6-
核心方法与API端点对应):
6+
核心方法 (与API端点对应) :
77
- exec_command(): 同步执行命令 -> /device/execute
8-
- exec_config(): 同步推送配置 -> /device/execute
8+
- exec_config(): 同步推送配置 -> /device/execute
99
- bulk_command(): 同步批量执行命令 -> /device/bulk
1010
- bulk_config(): 同步批量推送配置 -> /device/bulk
1111
- aexec_command(): 异步执行命令 -> /device/execute
@@ -23,34 +23,34 @@
2323
"""
2424

2525
# 核心客户端类
26+
from .async_client import AsyncJobHandle, AsyncNetPulseClient
2627
from .client import NetPulseClient
27-
from .async_client import AsyncNetPulseClient, AsyncJobHandle
28-
29-
# 数据模型
30-
from .models import (
31-
ConnectionArgs, # 主要的连接参数模型
32-
Device, # 向后兼容的Device别名
33-
CommandResult,
34-
ConfigResult,
35-
BatchResult,
36-
JobInfo,
37-
WorkerInfo,
38-
HealthCheckResult,
39-
ConnectionTestResult,
40-
)
41-
42-
# 工具函数
43-
from .models import create_device_request, create_batch_device_request
4428

4529
# 异常类
4630
from .exceptions import (
47-
NetPulseError,
4831
AuthenticationError,
4932
ConnectionError,
5033
JobError,
34+
NetPulseError,
35+
SDKValidationError,
5136
TimeoutError,
5237
ValidationError,
53-
SDKValidationError,
38+
)
39+
40+
# 数据模型
41+
# 工具函数
42+
from .models import (
43+
BatchResult,
44+
CommandResult,
45+
ConfigResult,
46+
ConnectionArgs, # 主要的连接参数模型
47+
ConnectionTestResult,
48+
Device, # 向后兼容的Device别名
49+
HealthCheckResult,
50+
JobInfo,
51+
WorkerInfo,
52+
create_batch_device_request,
53+
create_device_request,
5454
)
5555

5656
__version__ = "0.1.0"
@@ -60,7 +60,6 @@
6060
"NetPulseClient",
6161
"AsyncNetPulseClient",
6262
"AsyncJobHandle",
63-
6463
# 数据模型
6564
"ConnectionArgs", # 主要的连接参数模型
6665
"Device", # 向后兼容的Device别名
@@ -71,11 +70,9 @@
7170
"WorkerInfo",
7271
"HealthCheckResult",
7372
"ConnectionTestResult",
74-
7573
# 工具函数
7674
"create_device_request",
7775
"create_batch_device_request",
78-
7976
# 异常类
8077
"NetPulseError",
8178
"AuthenticationError",
@@ -84,4 +81,4 @@
8481
"TimeoutError",
8582
"ValidationError",
8683
"SDKValidationError",
87-
]
84+
]

0 commit comments

Comments
 (0)