π The fast, Pythonic way to build MCP servers and clients.
Remove private dead code and type-check the companion packages (#6454)
nate nowack713042447f2d
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex dbd632ad6..ed2dd1d99 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -29,7 +29,7 @@ repos:entry: uv run ty checklanguage: systemtypes: [python]- files: ^fastmcp_slim/|^tests/|^examples/+ files: ^fastmcp_slim/|^fastmcp_remote/|^fastmcp_tasks/|^tests/|^examples/pass_filenames: falserequire_serial: truediff --git a/fastmcp_slim/fastmcp/cli/cli.py b/fastmcp_slim/fastmcp/cli/cli.pyindex 8a4bca1e6..4a7972937 100644--- a/fastmcp_slim/fastmcp/cli/cli.py+++ b/fastmcp_slim/fastmcp/cli/cli.py@@ -61,18 +61,6 @@ def _get_npx_command():return "npx" # On Unix-like systems, just use npx-def _parse_env_var(env_var: str) -> tuple[str, str]:- """Parse environment variable string in format KEY=VALUE."""- if "=" not in env_var:- logger.error("Invalid environment variable format. Must be KEY=VALUE")- sys.exit(1)- key, value = env_var.split("=", 1)- if not key.strip():- logger.error("Invalid environment variable format. KEY cannot be empty")- sys.exit(1)- return key.strip(), value.strip()--@contextmanagerdef with_argv(args: list[str] | None):"""Temporarily replace sys.argv if args provided.diff --git a/fastmcp_slim/fastmcp/server/providers/local_provider/local_provider.py b/fastmcp_slim/fastmcp/server/providers/local_provider/local_provider.pyindex 9a1c1de76..d7789f12e 100644--- a/fastmcp_slim/fastmcp/server/providers/local_provider/local_provider.py+++ b/fastmcp_slim/fastmcp/server/providers/local_provider/local_provider.py@@ -215,17 +215,6 @@ class LocalProvider(del self._components[key]- def _get_component(self, key: str) -> FastMCPComponent | None:- """Get a component by its prefixed key.-- Args:- key: The prefixed key (e.g., "tool:name", "resource:uri").-- Returns:- The component, or None if not found.- """- return self._components.get(key)-def remove_tool(self, name: str, version: str | None = None) -> None:"""Remove tool(s) from this provider's storage.diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.pyindex a9dfe8b13..8e29d30cb 100644--- a/tests/cli/test_cli.py+++ b/tests/cli/test_cli.py@@ -5,7 +5,8 @@ from unittest.mock import Mock, patchimport pytest-from fastmcp.cli.cli import _parse_env_var, app+from fastmcp.cli.cli import app+from fastmcp.cli.install.shared import parse_env_varclass TestMainCLI:@@ -21,18 +22,18 @@ class TestMainCLI:def test_parse_env_var_valid(self):"""Test parsing valid environment variables."""- key, value = _parse_env_var("KEY=value")+ key, value = parse_env_var("KEY=value")assert key == "KEY"assert value == "value"- key, value = _parse_env_var("COMPLEX_KEY=complex=value=with=equals")+ key, value = parse_env_var("COMPLEX_KEY=complex=value=with=equals")assert key == "COMPLEX_KEY"assert value == "complex=value=with=equals"def test_parse_env_var_invalid(self):"""Test parsing invalid environment variables exits."""with pytest.raises(SystemExit) as exc_info:- _parse_env_var("INVALID_FORMAT")+ parse_env_var("INVALID_FORMAT")assert isinstance(exc_info.value, SystemExit)assert exc_info.value.code == 1diff --git a/tests/cli/test_shared.py b/tests/cli/test_shared.pyindex 17ab19c7f..a49798e45 100644--- a/tests/cli/test_shared.py+++ b/tests/cli/test_shared.py@@ -1,6 +1,5 @@import pytest-from fastmcp.cli.cli import _parse_env_varfrom fastmcp.cli.install.shared import parse_env_var@@ -9,29 +8,29 @@ class TestEnvVarParsing:def test_parse_env_var_simple(self):"""Test parsing simple environment variable."""- key, value = _parse_env_var("API_KEY=secret123")+ key, value = parse_env_var("API_KEY=secret123")assert key == "API_KEY"assert value == "secret123"def test_parse_env_var_with_equals_in_value(self):"""Test parsing env var with equals signs in the value."""- key, value = _parse_env_var("DATABASE_URL=postgresql://user:pass@host:5432/db")+ key, value = parse_env_var("DATABASE_URL=postgresql://user:pass@host:5432/db")assert key == "DATABASE_URL"assert value == "postgresql://user:pass@host:5432/db"def test_parse_env_var_with_spaces(self):"""Test parsing env var with spaces (should be stripped)."""- key, value = _parse_env_var(" API_KEY = secret with spaces ")+ key, value = parse_env_var(" API_KEY = secret with spaces ")assert key == "API_KEY"assert value == "secret with spaces"def test_parse_env_var_empty_value(self):"""Test parsing env var with empty value."""- key, value = _parse_env_var("EMPTY_VAR=")+ key, value = parse_env_var("EMPTY_VAR=")assert key == "EMPTY_VAR"assert value == ""- @pytest.mark.parametrize("parser", [_parse_env_var, parse_env_var])+ @pytest.mark.parametrize("parser", [parse_env_var])def test_parse_env_var_empty_key_exits(self, parser):"""Environment variable names cannot be empty."""with pytest.raises(SystemExit) as exc_info: