refactor: move inline imports to module level (#1893)

This commit is contained in:
Max Isbey 2026-01-16 15:54:08 +01:00 • committed by GitHub
commit 5d80f4efc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 58 additions and 122 deletions

View file

@ -1,5 +1,7 @@
"""Tests for OAuth 2.0 Resource Indicators utilities."""
from pydantic import HttpUrl
from mcp.shared.auth_utils import check_resource_allowed, resource_url_from_server_url
@ -37,8 +39,6 @@ class TestResourceUrlFromServerUrl:
def test_handles_pydantic_urls(self):
"""Should handle Pydantic URL types."""
from pydantic import HttpUrl
url = HttpUrl("https://example.com/path")
assert resource_url_from_server_url(url) == "https://example.com/path"

View file

@ -10,6 +10,7 @@ import json
import multiprocessing
import socket
import time
import traceback
from collections.abc import Generator
from typing import Any
from unittest.mock import MagicMock
@ -462,8 +463,6 @@ def run_server(
try:
server.run()
except Exception:
import traceback
traceback.print_exc()
@ -1100,8 +1099,6 @@ async def test_streamable_http_client_json_response(json_response_server: None,
@pytest.mark.anyio
async def test_streamable_http_client_get_stream(basic_server: None, basic_server_url: str):
"""Test GET stream functionality for server-initiated messages."""
import mcp.types as types
notifications_received: list[types.ServerNotification] = []
# Define message handler to capture notifications

View file

@ -3,6 +3,7 @@ import socket
import time
from collections.abc import AsyncGenerator, Generator
from typing import Any
from urllib.parse import urlparse
import anyio
import pytest
@ -50,8 +51,6 @@ class ServerTest(Server): # pragma: no cover
@self.read_resource()
async def handle_read_resource(uri: str) -> str | bytes:
from urllib.parse import urlparse
parsed = urlparse(uri)
if parsed.scheme == "foobar":
return f"Read {parsed.netloc}"