Skip to content

Commit fd0bc86

Browse files
TMHSDigitalclaude
andcommitted
style: satisfy ruff 0.16 default rules
Ruff 0.16 adds SIM, FURB, I and PLW1510 checks to the defaults, which failed the Dependabot bump in #53. Collapse nested ifs and withs, sort imports, use re.MULTILINE, and pass check=False explicitly. Still clean on ruff 0.15. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MpEiWjv38TrdFcgqU8ER5L
1 parent fa17222 commit fd0bc86

5 files changed

Lines changed: 27 additions & 32 deletions

File tree

‎.github/scripts/compile_csharp.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def compile_unit(csc, name, sources, refs, defines, out_dir, extra=()) -> bool:
7171
*[str(s) for s in sources],
7272
]
7373
rsp.write_text("\n".join(f'"{a}"' if " " in a else a for a in args), encoding="utf-8")
74-
result = subprocess.run([*csc, f"@{rsp}"], capture_output=True, text=True)
74+
result = subprocess.run([*csc, f"@{rsp}"], capture_output=True, text=True, check=False)
7575
if result.returncode != 0:
7676
print(f"FAIL {name}")
7777
for line in (result.stdout + result.stderr).splitlines():

‎.github/scripts/refresh_unity_data.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"""
1111

1212
import json
13+
import re
1314
import sys
14-
import urllib.request
1515
import urllib.error
16-
import re
16+
import urllib.request
1717
from pathlib import Path
1818

1919
DATA_DIR = Path("mcp-server/data")

‎.github/scripts/validate_plugin.py‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,20 @@ def check_content():
201201
for n, line in enumerate(text.splitlines(), 1):
202202
if DASHES.search(line):
203203
errors.append(f"{rel}:{n}: em or en dash; use a hyphen or rewrite")
204-
if rel.endswith((".cs", ".py", ".json")) and CREDENTIAL.search(line):
205-
if not any(word in line for word in CREDENTIAL_ALLOW):
206-
errors.append(f"{rel}:{n}: possible hardcoded credential")
204+
if (
205+
rel.endswith((".cs", ".py", ".json"))
206+
and CREDENTIAL.search(line)
207+
and not any(word in line for word in CREDENTIAL_ALLOW)
208+
):
209+
errors.append(f"{rel}:{n}: possible hardcoded credential")
207210
if rel.endswith(".cs") and FILE_SCOPED_NAMESPACE.search(text):
208211
errors.append(f"{rel}: file-scoped namespaces are C# 10; Unity 6 compiles C# 9")
209-
if rel.endswith((".md", ".mdc")) and rel.split("/")[0] in ("skills", "rules", "snippets", "templates"):
210-
if CSHARP10_ADVICE.search(text):
211-
errors.append(f"{rel}: recommends C# 10+ features that Unity 6 cannot compile")
212+
if (
213+
rel.endswith((".md", ".mdc"))
214+
and rel.split("/")[0] in ("skills", "rules", "snippets", "templates")
215+
and CSHARP10_ADVICE.search(text)
216+
):
217+
errors.append(f"{rel}: recommends C# 10+ features that Unity 6 cannot compile")
212218

213219
snippets = [p for p in (ROOT / "snippets").rglob("*") if p.is_file() and p.name != "README.md"]
214220
for p in snippets:

‎mcp-server/server.py‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,7 @@ def _check_data_files() -> None:
217217
}
218218

219219

220-
CSHARP_KEYWORDS = frozenset("""
221-
abstract as base bool break byte case catch char checked class const continue
222-
decimal default delegate do double else enum event explicit extern false finally
223-
fixed float for foreach goto if implicit in int interface internal is lock long
224-
namespace new null object operator out override params private protected public
225-
readonly ref return sbyte sealed short sizeof stackalloc static string struct
226-
switch this throw true try typeof uint ulong unchecked unsafe ushort using
227-
virtual void volatile while
228-
""".split())
220+
CSHARP_KEYWORDS = frozenset(["abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"])
229221

230222
_IDENTIFIER = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
231223

@@ -443,9 +435,8 @@ def shader_helper(
443435
results = []
444436

445437
for entry in shader_data:
446-
if effect_lower in entry.get("effect", "").lower():
447-
if pipeline in entry.get("pipelines", []):
448-
results.append(entry)
438+
if effect_lower in entry.get("effect", "").lower() and pipeline in entry.get("pipelines", []):
439+
results.append(entry)
449440

450441
if not results:
451442
effects = ", ".join(e.get("effect", "").lower() for e in shader_data)
@@ -590,13 +581,13 @@ def _is_text_yaml(text: str) -> bool:
590581

591582

592583
def _yaml_scalar(text: str, key: str) -> str | None:
593-
match = re.search(rf"^[ \t]*{re.escape(key)}:[ \t]*(.*?)\r?$", text, re.M)
584+
match = re.search(rf"^[ \t]*{re.escape(key)}:[ \t]*(.*?)\r?$", text, re.MULTILINE)
594585
return match.group(1).strip() if match else None
595586

596587

597588
def _yaml_platform_map(text: str, key: str) -> dict:
598589
"""Read a Unity per-platform map such as scriptingBackend: {Standalone: 1}."""
599-
match = re.search(rf"^([ \t]*){re.escape(key)}:[ \t]*\r?\n((?:\1[ \t]+.*\n?)*)", text, re.M)
590+
match = re.search(rf"^([ \t]*){re.escape(key)}:[ \t]*\r?\n((?:\1[ \t]+.*\n?)*)", text, re.MULTILINE)
600591
if not match:
601592
return {}
602593
result = {}
@@ -622,7 +613,7 @@ def _find_assets_by_guid(project: Path, guids: set) -> dict:
622613
if count >= _MAX_META_SCAN or len(found) == len(guids):
623614
break
624615
text = _read_text(meta) or ""
625-
match = re.search(r"^guid: ([0-9a-f]{32})", text, re.M)
616+
match = re.search(r"^guid: ([0-9a-f]{32})", text, re.MULTILINE)
626617
if match and match.group(1) in guids:
627618
found[match.group(1)] = meta.with_suffix("")
628619
return found

‎mcp-server/tests/test_server.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77

88
import pytest
9-
109
import server
1110

1211
SERVER_DIR = Path(__file__).resolve().parent.parent
@@ -220,13 +219,12 @@ def test_stdio_server_lists_and_calls_tools(tmp_path):
220219
)
221220

222221
async def run():
223-
async with stdio_client(params) as (read, write):
224-
async with ClientSession(read, write) as session:
225-
await session.initialize()
226-
tools = await session.list_tools()
227-
names = {tool.name for tool in tools.tools}
228-
result = await session.call_tool("platform_info", {"platform": "ios"})
229-
return names, result.content[0].text
222+
async with stdio_client(params) as (read, write), ClientSession(read, write) as session:
223+
await session.initialize()
224+
tools = await session.list_tools()
225+
names = {tool.name for tool in tools.tools}
226+
result = await session.call_tool("platform_info", {"platform": "ios"})
227+
return names, result.content[0].text
230228

231229
names, text = asyncio.run(asyncio.wait_for(run(), timeout=60))
232230
assert names == {"scaffold_script", "lookup_api", "shader_helper", "platform_info", "analyze_project"}

0 commit comments

Comments
 (0)