Skip to content

Commit 71e511c

Browse files
authored
Merge pull request #18 from IthacaDream/chore/format-and-style
chore: fix formatting and lint checking issues
2 parents f56248e + 0a974a9 commit 71e511c

File tree

18 files changed

+79
-82
lines changed

18 files changed

+79
-82
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ repos:
1414
require_serial: true
1515
additional_dependencies: []
1616

17-
- id: ruff
18-
name: ruff
17+
- id: ruff-check
18+
name: ruff-check
1919
description: "Run 'ruff' for extremely fast Python linting"
2020
entry: uv run --dev ruff check
2121
pass_filenames: false

.ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
target-version = "py310"
12
exclude = ["docs/**"]
23
line-length = 120
34

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We welcome contributions! These guidelines exist to save everyone time. Followin
1010

1111
## Development Setup
1212

13-
1. Make sure you have `Python 3.12+` installed.
13+
1. Make sure you have `Python 3.10+` installed.
1414
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/).
1515
1. Fork the repository and clone your fork.
1616
1. Install development dependencies: `make prepare`.

examples/jetarm_demo/connect_pychannel_with_rcply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import asyncio
21
import argparse
2+
import asyncio
33

44
from ghoshell_moss.transports.zmq_channel.zmq_channel import ZMQChannelProxy
55

examples/jetarm_demo/jetarm_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import argparse
12
import asyncio
3+
from pathlib import Path
24

35
from ghoshell_container import Container
4-
import argparse
56

67
from ghoshell_moss.core.shell import new_shell
78
from ghoshell_moss.speech import make_baseline_tts_speech
@@ -10,8 +11,7 @@
1011
from ghoshell_moss.transports.zmq_channel.zmq_channel import ZMQChannelProxy
1112
from ghoshell_moss_contrib.agent import ModelConf, SimpleAgent
1213
from ghoshell_moss_contrib.agent.chat import ConsoleChat
13-
from ghoshell_moss_contrib.example_ws import workspace_container, get_container
14-
from pathlib import Path
14+
from ghoshell_moss_contrib.example_ws import get_container, workspace_container
1515

1616
ADDRESS = "tcp://192.168.1.15:9527"
1717
"""填入正确的 ip, 需要先对齐 jetarm_ws 运行的机器设备和监听的端口. """

examples/miku/main.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1+
import asyncio
2+
import importlib.util
13
import os
24
import sys
3-
4-
from ghoshell_moss.speech import make_baseline_tts_speech, Speech
5-
from ghoshell_moss.speech.player.pyaudio_player import PyAudioStreamPlayer
6-
from ghoshell_moss.speech.volcengine_tts import VolcengineTTS, VolcengineTTSConf
7-
from ghoshell_moss_contrib.agent import ModelConf, SimpleAgent
8-
9-
import asyncio
105
from os.path import dirname, join
116

127
import live2d.v3 as live2d
138
import pygame
149
from ghoshell_container import Container
1510

11+
from ghoshell_moss.speech import Speech, make_baseline_tts_speech
12+
from ghoshell_moss.speech.player.pyaudio_player import PyAudioStreamPlayer
13+
from ghoshell_moss.speech.volcengine_tts import VolcengineTTS, VolcengineTTSConf
14+
from ghoshell_moss_contrib.agent import ModelConf, SimpleAgent
15+
1616
current_dir = os.path.dirname(os.path.abspath(__file__))
17-
try:
18-
import miku_channels
19-
except ImportError:
17+
if importlib.util.find_spec(miku_channels) is None:
2018
# 加载当前路径.
2119
sys.path.append(current_dir)
2220

21+
import pathlib
22+
2323
from miku_channels.arm import left_arm_chan, right_arm_chan
2424
from miku_channels.body import body_chan
2525
from miku_channels.elbow import left_elbow_chan, right_elbow_chan
@@ -30,9 +30,9 @@
3030
from miku_channels.leg import left_leg_chan, right_leg_chan
3131
from miku_channels.necktie import necktie_chan
3232
from miku_provider import init_live2d, init_pygame
33+
3334
from ghoshell_moss.core.shell import new_shell
34-
from ghoshell_moss_contrib.example_ws import workspace_container, get_example_speech
35-
import pathlib
35+
from ghoshell_moss_contrib.example_ws import get_example_speech, workspace_container
3636

3737
# 全局状态
3838
WIDTH = 600

examples/miku/miku_provider.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import importlib.util
23
import os
34
import sys
45
from os.path import dirname, join
@@ -7,10 +8,8 @@
78
import pygame
89
from ghoshell_container import Container, get_container
910

10-
try:
11-
import miku_channels
12-
except ImportError:
13-
current_dir = os.path.dirname(os.path.abspath(__file__))
11+
current_dir = os.path.dirname(os.path.abspath(__file__))
12+
if importlib.util.find_spec(miku_channels) is None:
1413
sys.path.append(current_dir)
1514

1615
from miku_channels.arm import left_arm_chan, right_arm_chan
@@ -22,8 +21,9 @@
2221
from miku_channels.head import head_chan
2322
from miku_channels.leg import left_leg_chan, right_leg_chan
2423
from miku_channels.necktie import necktie_chan
25-
from ghoshell_moss.transports.zmq_channel import ZMQChannelProvider
24+
2625
from ghoshell_moss import Channel
26+
from ghoshell_moss.transports.zmq_channel import ZMQChannelProvider
2727

2828
# 全局状态
2929
model: live2d.LAppModel | None = None

examples/moss_agent.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
import os.path
2-
import pathlib
31
import asyncio
2+
import pathlib
43

5-
from ghoshell_common.contracts import Workspace, LoggerItf
4+
from ghoshell_common.contracts import LoggerItf, Workspace
65
from ghoshell_container import Container
76

8-
from ghoshell_moss_contrib.example_ws import workspace_container, get_example_speech
9-
from ghoshell_moss.channels.mac_channel import new_mac_control_channel
10-
from ghoshell_moss_contrib.channels.mermaid_draw import new_mermaid_chan
11-
from ghoshell_moss_contrib.channels.web_bookmark import build_web_bookmark_chan
12-
13-
from ghoshell_moss_contrib.agent import SimpleAgent, ModelConf, ConsoleChat
147
from ghoshell_moss.core.shell import new_shell
15-
from ghoshell_moss.transports.zmq_channel.zmq_hub import ZMQChannelHub, ZMQHubConfig, ZMQProxyConfig
168

179
# 不着急删除, 方便自测时开启.
18-
from ghoshell_moss_contrib.channels.screen_capture import ScreenCapture
19-
from ghoshell_moss.transports.zmq_channel.zmq_hub import ZMQChannelProxy
10+
from ghoshell_moss.transports.zmq_channel.zmq_hub import ZMQChannelHub, ZMQHubConfig, ZMQProxyConfig
11+
from ghoshell_moss_contrib.agent import ConsoleChat, ModelConf, SimpleAgent
12+
from ghoshell_moss_contrib.channels.mermaid_draw import new_mermaid_chan
13+
from ghoshell_moss_contrib.channels.web_bookmark import build_web_bookmark_chan
14+
from ghoshell_moss_contrib.example_ws import get_example_speech, workspace_container
2015

2116
"""
2217
说明:
@@ -118,11 +113,11 @@ def run_moss_agent(container: Container):
118113
instruction=instructions,
119114
chat=ConsoleChat(logger=logger),
120115
model=ModelConf(
121-
kwargs=dict(
122-
thinking=dict(
123-
type="disabled",
124-
)
125-
),
116+
kwargs={
117+
"thinking": {
118+
"type": "disabled",
119+
},
120+
},
126121
),
127122
shell=shell,
128123
)

examples/moss_zmq_channels/miku_app.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
from os.path import dirname, join
21
import sys
2+
from os.path import dirname, join
33

44
# patch miku 的读取路径.
55
# 由于 miku 还是一个实验性的数字人项目, 暂时不希望把它打包到 ghoshell_moss_contrib 里 (太大)
66
# 所以先用比较脏的相对路径来读取它.
77
current_dir = dirname(__file__)
88
workspace_dir = join(dirname(current_dir), ".workspace")
9-
try:
10-
import miku
11-
except ImportError:
12-
miku_dir = join(dirname(current_dir), "miku")
13-
print(miku_dir)
9+
miku_dir = join(dirname(current_dir), "miku")
10+
if miku_dir not in sys.path:
1411
sys.path.append(miku_dir)
15-
from miku_provider import run_game_with_zmq_provider
1612

1713
import asyncio
14+
15+
from miku_provider import run_game_with_zmq_provider
16+
1817
from ghoshell_moss_contrib.example_ws import workspace_container
1918

2019
if __name__ == "__main__":

examples/moss_zmq_channels/vision_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from ghoshell_moss_contrib.channels.opencv_vision import OpenCVVision
21
from ghoshell_moss import get_container
32
from ghoshell_moss.transports.zmq_channel import ZMQChannelProvider
3+
from ghoshell_moss_contrib.channels.opencv_vision import OpenCVVision
44

55
if __name__ == "__main__":
66
# 初始化容器

0 commit comments

Comments
 (0)