Skip to content

Commit 7dafac9

Browse files
authored
Merge pull request #54 from nitrocloudofficial/fix/validate-skip-vendored-sdk
validate: skip the vendored SDK
2 parents 1917995 + b96606b commit 7dafac9

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎nitrostack/cli/validators.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
read_text,
2222
split_requirement,
2323
)
24+
from nitrostack.cli.vendor import VENDOR_REL
2425

2526

2627
@dataclass
@@ -39,10 +40,14 @@ def format(self) -> str:
3940

4041

4142
def _iter_python_files(root: str) -> Iterable[str]:
43+
# The vendored SDK is not project code; its testing helpers apply @mcp_app
44+
# inside functions, which reads as an app with no decorated class.
45+
vendored_sdk = os.path.join(os.path.abspath(root), VENDOR_REL)
4246
for dirpath, dirnames, filenames in os.walk(root):
4347
dirnames[:] = [
4448
d for d in dirnames
4549
if d not in EXCLUDE_DIR_NAMES and not d.endswith(".egg-info")
50+
and os.path.join(os.path.abspath(dirpath), d) != vendored_sdk
4651
]
4752
for filename in filenames:
4853
if filename.endswith(".py"):

‎tests/test_cli.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,33 @@ def test_validate_catches_broken_imports_and_module_refs(tmp_path: Path):
11541154
assert "→" in messages or "Fix the import" in messages
11551155

11561156

1157+
def test_validate_skips_the_vendored_sdk(tmp_path: Path):
1158+
"""`init` vendors the SDK; its testing helpers apply @mcp_app inside functions."""
1159+
(tmp_path / "pyproject.toml").write_text(
1160+
"[project]\n"
1161+
'name = "vendored"\n'
1162+
'version = "0.1.0"\n'
1163+
"dependencies = [\n"
1164+
' "nitrostack",\n'
1165+
"]\n",
1166+
encoding="utf-8",
1167+
)
1168+
sdk = tmp_path / "vendor" / "nitrostack" / "nitrostack" / "testing"
1169+
sdk.mkdir(parents=True)
1170+
(sdk / "__init__.py").write_text(
1171+
"from nitrostack import mcp_app, ServerConfig\n\n"
1172+
"def create(module):\n"
1173+
" @mcp_app(module=module, server=ServerConfig(name='test'))\n"
1174+
" class TestApp:\n"
1175+
" pass\n"
1176+
" return TestApp\n",
1177+
encoding="utf-8",
1178+
)
1179+
1180+
issues = validate_project(str(tmp_path))
1181+
assert not [issue for issue in issues if "vendor" in issue.path], [i.format() for i in issues]
1182+
1183+
11571184
def test_validate_accepts_module_only_bootstrap(tmp_path: Path):
11581185
"""Init templates use @module + McpApplicationFactory.create — no @mcp_app."""
11591186
(tmp_path / "pyproject.toml").write_text(

0 commit comments

Comments
 (0)