Skip to content

Commit e24c445

Browse files
authored
add ruff hooks + actions (#79)
* hook * add hooks * hook * format
1 parent 4b73c16 commit e24c445

File tree

12 files changed

+51
-31
lines changed

12 files changed

+51
-31
lines changed

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v3
14+
- uses: pre-commit/[email protected]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ __pycache__/
3434
*.egg-info/
3535
.venv/
3636

37+
# Ruff
38+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.2
4+
hooks:
5+
- id: ruff-check
6+
- id: ruff-format
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v6.0.0
9+
hooks:
10+
- id: check-yaml
11+
- id: check-json
12+
- id: end-of-file-fixer
13+
- id: requirements-txt-fixer
14+
- id: trailing-whitespace

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ The MCP servers in this demo highlight how each tool can light up widgets by com
3333
- Node.js 18+
3434
- pnpm (recommended) or npm/yarn
3535
- Python 3.10+ (for the Python MCP server)
36+
- pre-commit for formatting
3637

3738
## Install dependencies
3839

3940
Clone the repository and install the workspace dependencies:
4041

4142
```bash
4243
pnpm install
44+
pre-commit install
4345
```
4446

4547
> Using npm or yarn? Install the root dependencies with your preferred client and adjust the commands below accordingly.

dev-all.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,3 @@ main().catch((e) => {
115115
console.error(e);
116116
process.exit(1);
117117
});
118-

pizzaz_server_python/main.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,19 @@ def _load_widget_html(component_name: str) -> str:
8686
invoked="Served a fresh list",
8787
html=_load_widget_html("pizzaz-list"),
8888
response_text="Rendered a pizza list!",
89-
)
89+
),
9090
]
9191

9292

9393
MIME_TYPE = "text/html+skybridge"
9494

9595

96-
WIDGETS_BY_ID: Dict[str, PizzazWidget] = {widget.identifier: widget for widget in widgets}
97-
WIDGETS_BY_URI: Dict[str, PizzazWidget] = {widget.template_uri: widget for widget in widgets}
96+
WIDGETS_BY_ID: Dict[str, PizzazWidget] = {
97+
widget.identifier: widget for widget in widgets
98+
}
99+
WIDGETS_BY_URI: Dict[str, PizzazWidget] = {
100+
widget.template_uri: widget for widget in widgets
101+
}
98102

99103

100104
class PizzaInput(BaseModel):
@@ -138,7 +142,7 @@ def _tool_meta(widget: PizzazWidget) -> Dict[str, Any]:
138142
"openai/toolInvocation/invoking": widget.invoking,
139143
"openai/toolInvocation/invoked": widget.invoked,
140144
"openai/widgetAccessible": True,
141-
"openai/resultCanProduceWidget": True
145+
"openai/resultCanProduceWidget": True,
142146
}
143147

144148

@@ -277,7 +281,7 @@ async def _call_tool_request(req: types.CallToolRequest) -> types.ServerResult:
277281
)
278282
],
279283
structuredContent={"pizzaTopping": topping},
280-
_meta=meta
284+
_meta=meta,
281285
)
282286
)
283287

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mcp[fastapi]>=0.1.0
21
fastapi>=0.115.0
2+
mcp[fastapi]>=0.1.0
33
uvicorn>=0.30.0

solar-system_server_python/main.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ def _tool_meta(widget: SolarWidget) -> Dict[str, Any]:
125125
"openai/widgetAccessible": True,
126126
"openai/resultCanProduceWidget": True,
127127
"annotations": {
128-
"destructiveHint": False,
129-
"openWorldHint": False,
130-
"readOnlyHint": True,
131-
}
128+
"destructiveHint": False,
129+
"openWorldHint": False,
130+
"readOnlyHint": True,
131+
},
132132
}
133133

134134

@@ -152,10 +152,10 @@ def _normalize_planet(name: str) -> str | None:
152152
if not key:
153153
return DEFAULT_PLANET
154154

155-
clean = ''.join(ch for ch in key if ch.isalnum())
155+
clean = "".join(ch for ch in key if ch.isalnum())
156156

157157
for planet in PLANETS:
158-
planet_key = ''.join(ch for ch in planet.lower() if ch.isalnum())
158+
planet_key = "".join(ch for ch in planet.lower() if ch.isalnum())
159159
if clean == planet_key or key == planet.lower():
160160
return planet
161161

@@ -164,7 +164,7 @@ def _normalize_planet(name: str) -> str | None:
164164
return alias
165165

166166
for planet in PLANETS:
167-
planet_key = ''.join(ch for ch in planet.lower() if ch.isalnum())
167+
planet_key = "".join(ch for ch in planet.lower() if ch.isalnum())
168168
if planet_key.startswith(clean):
169169
return planet
170170

@@ -259,10 +259,7 @@ async def _call_tool_request(req: types.CallToolRequest) -> types.ServerResult:
259259
content=[
260260
types.TextContent(
261261
type="text",
262-
text=(
263-
"Unknown planet. Provide one of: "
264-
+ ", ".join(PLANETS)
265-
),
262+
text=("Unknown planet. Provide one of: " + ", ".join(PLANETS)),
266263
)
267264
],
268265
isError=True,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
fastapi>=0.115.0
12
# Dependencies for the solar-system MCP demo server
23
mcp[fastapi]>=0.1.0
3-
fastapi>=0.115.0
44
uvicorn>=0.30.0

src/pizzaz-albums/albums.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,3 @@
110110
}
111111
]
112112
}
113-
114-

0 commit comments

Comments
 (0)