mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
* fix: filesystem provider import machinery - Temporary sys.path entries (both package and non-package mode) now removed immediately after exec_module via try/finally, eliminating permanent process-wide pollution - Non-package files use bare stem as sys.modules key only if unclaimed; falls back to private hash-based key to prevent stdlib shadowing (e.g. json.py clobbering json) - Reload of private-key modules uses spec.loader.exec_module directly instead of importlib.reload, which cannot find files by their private synthetic name - _find_package_root gains stop_at parameter; discover_and_import passes provider_root to prevent package root discovery from escaping above the provider boundary Closes #3625 (issues 2, 3, 6) 🤖 Generated with Claude Code * fix: use contextlib.suppress for SIM105 linting 🤖 Generated with Claude Code * test: add import machinery regression tests 🤖 Generated with Claude Code * fix: resolve provider_root before path comparison; improve tests - Resolve provider_root in import_module_from_file so the stop_at boundary in _find_package_root works correctly when provider_root is a relative path (e.g. FileSystemProvider(Path("./mcp"))) — previously the resolved file_path and unresolved stop_at.parent would never compare equal - Fix test_stdlib_not_shadowed: use unconditional finally to restore sys.modules["json"] - Strengthen test_same_stem_files: assert mod_a is not mod_b and that sys.modules["helpers"] was not clobbered by the second import - Replace direct _find_package_root unit test with an integration test through import_module_from_file(provider_root=...) that also verifies the module name and that tmp_path is not added to sys.path 🤖 Generated with Claude Code |
||
|---|---|---|
| .. | ||
| test_discovery.py | ||
| test_provider.py | ||