Skip to content

Commit b8e97a0

Browse files
committed
Address review: quote "$@", fail the README check closed, reword the ruff preview note
- scripts/test: forward arguments as "$@". - scripts/update_readme_snippets.py: a per-block error now exits non-zero instead of printing and keeping the stale block, which let --check pass; the missing-file special case that worked around that goes away. - pyproject.toml: say what lint.preview actually turns on. - path_security docstring: the copy-paste example passes encoding= too.
1 parent 6c27385 commit b8e97a0

4 files changed

Lines changed: 8 additions & 15 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ line-length = 120
195195
target-version = "py310"
196196

197197
[tool.ruff.lint]
198-
# preview + explicit-preview-rules enables exactly one preview rule: PLW1514 (text I/O without encoding=).
198+
# lint.preview is required to select PLW1514 (text I/O without encoding=); it also opts the stable rules into their
199+
# preview behaviours and fixes. explicit-preview-rules only stops the prefixes below pulling in other preview rules.
199200
preview = true
200201
explicit-preview-rules = true
201202
extend-select = ["PLW1514"]

scripts/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -ex
44

55
uv run --frozen coverage erase
66
# PYTHONWARNDEFAULTENCODING=1 mirrors CI: text I/O without encoding= fails under pytest's "error" filter.
7-
PYTHONWARNDEFAULTENCODING=1 uv run --frozen coverage run -m pytest -n auto $@
7+
PYTHONWARNDEFAULTENCODING=1 uv run --frozen coverage run -m pytest -n auto "$@"
88
uv run --frozen coverage combine
99
uv run --frozen coverage report
1010
# strict-no-cover spawns `uv run coverage json` internally without --frozen;

scripts/update_readme_snippets.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@ def process_snippet_block(match: re.Match[str], check_mode: bool = False) -> str
4343
file_path = match.group(2)
4444

4545
try:
46-
# Read the entire file. A missing source file must be fatal: a "Warning"
47-
# that returns the stale block lets --check pass with exit 0, so a
48-
# renamed or deleted snippet is invisible to CI. SystemExit deliberately
49-
# escapes the `except Exception` below.
50-
file = Path(file_path)
51-
if not file.exists():
52-
sys.exit(f"Error: snippet-source file not found: {file_path}")
53-
54-
code = file.read_text(encoding="utf-8").rstrip()
46+
code = Path(file_path).read_text(encoding="utf-8").rstrip()
5547
github_url = get_github_url(file_path)
5648

5749
# Build the replacement block
@@ -88,9 +80,9 @@ def process_snippet_block(match: re.Match[str], check_mode: bool = False) -> str
8880

8981
return replacement
9082

91-
except Exception as e:
92-
print(f"Error processing {file_path}: {e}")
93-
return full_match
83+
except OSError as e:
84+
# Fatal, not "warn and keep the stale block": that would let --check pass with exit 0.
85+
sys.exit(f"Error processing {file_path}: {e}")
9486

9587

9688
def update_readme_snippets(check_mode: bool = False) -> bool:

src/mcp/shared/path_security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
@mcp.resource("file://docs/{+path}")
1414
def read_doc(path: str) -> str:
15-
return safe_join("/data/docs", path).read_text()
15+
return safe_join("/data/docs", path).read_text(encoding="utf-8")
1616
"""
1717

1818
import string

0 commit comments

Comments
 (0)