Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Bump ty to ==0.0.1a25 (#2350)

Jeremiah Lowin6cc9559f84cc
diff --git a/pyproject.toml b/pyproject.toml
index 439d5bdf8..627a5a704 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -71,7 +71,7 @@ dev = [
"pytest-timeout>=2.4.0",
"pytest-xdist>=3.6.1",
"ruff>=0.12.8",
- "ty==0.0.1a19",
+ "ty==0.0.1a25",
"prek>=0.2.12",
]
@@ -136,12 +136,17 @@ python-version = "3.10"
[tool.ty.rules]
# Rules with too many errors to fix right now (40+ each)
-no-matching-overload = "ignore" # 126 errors
+no-matching-overload = "ignore" # 126 errors
unknown-argument = "ignore" # 61 errors
# Rules with moderate errors that need more investigation
call-non-callable = "ignore" # 7 errors
+# NOTE: ty currently doesn't support type narrowing with isinstance() on unions
+# See: https://github.com/astral-sh/ty/issues/122 and https://github.com/astral-sh/ty/issues/1113
+# Some code uses `# ty: ignore[invalid-argument-type]` for this limitation.
+# TODO: Remove these ignores once ty supports union narrowing
+
[tool.ruff.lint]
fixable = ["ALL"]
ignore = [
diff --git a/src/fastmcp/client/auth/oauth.py b/src/fastmcp/client/auth/oauth.py
index f454febec..fd5056fdd 100644
--- a/src/fastmcp/client/auth/oauth.py
+++ b/src/fastmcp/client/auth/oauth.py
@@ -297,7 +297,8 @@ class OAuth(OAuthClientProvider):
response = None
while True:
try:
- yielded_request = await gen.asend(response)
+ # First iteration sends None, subsequent iterations send response
+ yielded_request = await gen.asend(response) # ty: ignore[invalid-argument-type]
response = yield yielded_request
except StopAsyncIteration:
break
@@ -306,16 +307,16 @@ class OAuth(OAuthClientProvider):
logger.debug(
"OAuth client not found on server, clearing cache and retrying..."
)
-
# Clear cached state and retry once
self._initialized = False
await self.token_storage_adapter.clear()
+ # Retry with fresh registration
gen = super().async_auth_flow(request)
response = None
while True:
try:
- yielded_request = await gen.asend(response)
+ yielded_request = await gen.asend(response) # ty: ignore[invalid-argument-type]
response = yield yielded_request
except StopAsyncIteration:
break
diff --git a/src/fastmcp/client/client.py b/src/fastmcp/client/client.py
index aa6fb30c2..9c5201b94 100644
--- a/src/fastmcp/client/client.py
+++ b/src/fastmcp/client/client.py
@@ -240,6 +240,7 @@ class Client(Generic[ClientTransportT]):
self._progress_handler = progress_handler
+ # Convert timeout to timedelta if needed
if isinstance(timeout, int | float):
timeout = datetime.timedelta(seconds=float(timeout))
@@ -259,7 +260,7 @@ class Client(Generic[ClientTransportT]):
"list_roots_callback": None,
"logging_callback": create_log_callback(log_handler),
"message_handler": message_handler,
- "read_timeout_seconds": timeout,
+ "read_timeout_seconds": timeout, # ty: ignore[invalid-argument-type]
"client_info": client_info,
}
@@ -852,12 +853,13 @@ class Client(Generic[ClientTransportT]):
"""
logger.debug(f"[{self.name}] called call_tool: {name}")
+ # Convert timeout to timedelta if needed
if isinstance(timeout, int | float):
timeout = datetime.timedelta(seconds=float(timeout))
result = await self.session.call_tool(
name=name,
arguments=arguments,
- read_timeout_seconds=timeout,
+ read_timeout_seconds=timeout, # ty: ignore[invalid-argument-type]
progress_callback=progress_handler or self._progress_handler,
)
return result
diff --git a/src/fastmcp/experimental/utilities/openapi/director.py b/src/fastmcp/experimental/utilities/openapi/director.py
index eb8b280fc..2efc8e74c 100644
--- a/src/fastmcp/experimental/utilities/openapi/director.py
+++ b/src/fastmcp/experimental/utilities/openapi/director.py
@@ -54,28 +54,27 @@ class RequestDirector:
url = self._build_url(route.path, path_params, base_url)
# Step 3: Prepare request data
- request_data = {
- "method": route.method.upper(),
- "url": url,
- "params": query_params if query_params else None,
- "headers": header_params if header_params else None,
- }
+ method: str = route.method.upper()
+ params = query_params if query_params else None
+ headers = header_params if header_params else None
+ json_body: dict[str, Any] | list[Any] | None = None
+ content: str | bytes | None = None
# Step 4: Handle request body
if body is not None:
if isinstance(body, dict | list):
- request_data["json"] = body
+ json_body = body
else:
- request_data["content"] = body
+ content = body
# Step 5: Create httpx.Request
return httpx.Request(
- method=request_data["method"],
- url=request_data["url"],
- params=request_data.get("params"),
- headers=request_data.get("headers"),
- json=request_data.get("json"),
- content=request_data.get("content"),
+ method=method,
+ url=url,
+ params=params,
+ headers=headers,
+ json=json_body,
+ content=content,
)
def _unflatten_arguments(
diff --git a/src/fastmcp/mcp_config.py b/src/fastmcp/mcp_config.py
index 878d60faf..4d8d8283b 100644
--- a/src/fastmcp/mcp_config.py
+++ b/src/fastmcp/mcp_config.py
@@ -101,7 +101,7 @@ class _TransformingMCPServerMixin(FastMCPBaseModel):
ClientTransport, # pyright: ignore[reportUnusedImport]
)
- transport: ClientTransport = super().to_transport() # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue, reportUnknownVariableType]
+ transport: ClientTransport = super().to_transport() # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue, reportUnknownVariableType] # ty: ignore[unresolved-attribute]
transport = cast(ClientTransport, transport)
client: Client[ClientTransport] = Client(transport=transport, name=client_name)
diff --git a/src/fastmcp/server/auth/handlers/authorize.py b/src/fastmcp/server/auth/handlers/authorize.py
index 13c98a56d..f91b266b7 100644
--- a/src/fastmcp/server/auth/handlers/authorize.py
+++ b/src/fastmcp/server/auth/handlers/authorize.py
@@ -13,6 +13,7 @@ The enhancement adds:
from __future__ import annotations
+import json
from typing import TYPE_CHECKING
from mcp.server.auth.handlers.authorize import (
@@ -211,12 +212,15 @@ class AuthorizationHandler(SDKAuthorizationHandler):
# Check if this is a client not found error
if response.status_code == 400:
# Try to extract client_id from request for enhanced error
- client_id = None
+ client_id: str | None = None
if request.method == "GET":
client_id = request.query_params.get("client_id")
else:
form = await request.form()
- client_id = form.get("client_id")
+ client_id_value = form.get("client_id")
+ # Ensure client_id is a string, not UploadFile
+ if isinstance(client_id_value, str):
+ client_id = client_id_value
# If we have a client_id and the error is about it not being found,
# enhance the response
@@ -224,9 +228,7 @@ class AuthorizationHandler(SDKAuthorizationHandler):
try:
# Check if response body contains "not found" error
if hasattr(response, "body"):
- import json
-
- body = json.loads(response.body)
+ body = json.loads(bytes(response.body))
if (
body.get("error") == "invalid_request"
and "not found" in body.get("error_description", "").lower()
diff --git a/src/fastmcp/server/auth/oauth_proxy.py b/src/fastmcp/server/auth/oauth_proxy.py
index 6f1336d96..9bfdd3595 100644
--- a/src/fastmcp/server/auth/oauth_proxy.py
+++ b/src/fastmcp/server/auth/oauth_proxy.py
@@ -1605,9 +1605,10 @@ class OAuthProxy(OAuthProvider):
):
authorize_route_found = True
# Replace with our enhanced authorization handler
+ # Note: self.base_url is guaranteed to be set in parent __init__
authorize_handler = AuthorizationHandler(
provider=self,
- base_url=self.base_url,
+ base_url=self.base_url, # ty: ignore[invalid-argument-type]
server_name=None, # Could be extended to pass server metadata
server_icon_url=None,
)
diff --git a/src/fastmcp/server/auth/oidc_proxy.py b/src/fastmcp/server/auth/oidc_proxy.py
index d9a3df510..7b1173eae 100644
--- a/src/fastmcp/server/auth/oidc_proxy.py
+++ b/src/fastmcp/server/auth/oidc_proxy.py
@@ -340,7 +340,7 @@ class OIDCProxy(OAuthProxy):
init_kwargs["extra_authorize_params"] = extra_params
init_kwargs["extra_token_params"] = extra_params
- super().__init__(**init_kwargs)
+ super().__init__(**init_kwargs) # ty: ignore[invalid-argument-type]
def get_oidc_configuration(
self,
diff --git a/src/fastmcp/server/auth/providers/descope.py b/src/fastmcp/server/auth/providers/descope.py
index 43163c6f8..9e89339aa 100644
--- a/src/fastmcp/server/auth/providers/descope.py
+++ b/src/fastmcp/server/auth/providers/descope.py
@@ -102,7 +102,7 @@ class DescopeProvider(RemoteAuthProvider):
)
self.project_id = settings.project_id
- self.base_url = str(settings.base_url).rstrip("/")
+ self.base_url = AnyHttpUrl(str(settings.base_url).rstrip("/"))
self.descope_base_url = str(settings.descope_base_url).rstrip("/")
# Create default JWT verifier if none provided
diff --git a/src/fastmcp/server/auth/providers/supabase.py b/src/fastmcp/server/auth/providers/supabase.py
index 13cb41e93..8468488bf 100644
--- a/src/fastmcp/server/auth/providers/supabase.py
+++ b/src/fastmcp/server/auth/providers/supabase.py
@@ -107,7 +107,7 @@ class SupabaseProvider(RemoteAuthProvider):
)
self.project_url = str(settings.project_url).rstrip("/")
- self.base_url = str(settings.base_url).rstrip("/")
+ self.base_url = AnyHttpUrl(str(settings.base_url).rstrip("/"))
# Create default JWT verifier if none provided
if token_verifier is None:
diff --git a/src/fastmcp/server/auth/providers/workos.py b/src/fastmcp/server/auth/providers/workos.py
index 1d87ff5ec..14b6a55a3 100644
--- a/src/fastmcp/server/auth/providers/workos.py
+++ b/src/fastmcp/server/auth/providers/workos.py
@@ -362,7 +362,7 @@ class AuthKitProvider(RemoteAuthProvider):
)
self.authkit_domain = str(settings.authkit_domain).rstrip("/")
- self.base_url = str(settings.base_url).rstrip("/")
+ self.base_url = AnyHttpUrl(str(settings.base_url).rstrip("/"))
# Create default JWT verifier if none provided
if token_verifier is None:
diff --git a/src/fastmcp/server/middleware/logging.py b/src/fastmcp/server/middleware/logging.py
index 593ce3bbf..af2eff4b4 100644
--- a/src/fastmcp/server/middleware/logging.py
+++ b/src/fastmcp/server/middleware/logging.py
@@ -46,7 +46,7 @@ class BaseLoggingMiddleware(Middleware):
return payload
- def _format_message(self, message: dict[str, str | int]) -> str:
+ def _format_message(self, message: dict[str, str | int | float]) -> str:
"""Format a message for logging."""
if self.structured_logging:
return json.dumps(message)
@@ -55,7 +55,7 @@ class BaseLoggingMiddleware(Middleware):
def _create_before_message(
self, context: MiddlewareContext[Any]
- ) -> dict[str, str | int]:
+ ) -> dict[str, str | int | float]:
message = {
"event": context.type + "_start",
"method": context.method or "unknown",
diff --git a/src/fastmcp/server/proxy.py b/src/fastmcp/server/proxy.py
index dc87e98b7..deba4eec1 100644
--- a/src/fastmcp/server/proxy.py
+++ b/src/fastmcp/server/proxy.py
@@ -539,7 +539,7 @@ class ProxyClient(Client[ClientTransportT]):
def __init__(
self,
transport: ClientTransportT
- | FastMCP
+ | FastMCP[Any]
| FastMCP1Server
| AnyUrl
| Path
diff --git a/src/fastmcp/server/server.py b/src/fastmcp/server/server.py
index 1ce5fbf38..5f3931dda 100644
--- a/src/fastmcp/server/server.py
+++ b/src/fastmcp/server/server.py
@@ -79,6 +79,7 @@ from fastmcp.utilities.types import NotSet, NotSetT
if TYPE_CHECKING:
from fastmcp.client import Client
+ from fastmcp.client.client import FastMCP1Server
from fastmcp.client.transports import ClientTransport, ClientTransportT
from fastmcp.experimental.server.openapi import FastMCPOpenAPI as FastMCPOpenAPINew
from fastmcp.experimental.server.openapi.routing import (
@@ -1045,7 +1046,11 @@ class FastMCP(Generic[LifespanResultT]):
async def _call_tool_mcp(
self, key: str, arguments: dict[str, Any]
- ) -> list[ContentBlock] | tuple[list[ContentBlock], dict[str, Any]]:
+ ) -> (
+ list[ContentBlock]
+ | tuple[list[ContentBlock], dict[str, Any]]
+ | mcp.types.CallToolResult
+ ):
"""
Handle MCP 'callTool' requests.
@@ -1488,7 +1493,7 @@ class FastMCP(Generic[LifespanResultT]):
icons=icons,
tags=tags,
output_schema=output_schema,
- annotations=cast(ToolAnnotations | None, annotations),
+ annotations=annotations,
exclude_args=exclude_args,
meta=meta,
serializer=self._tool_serializer,
@@ -1721,7 +1726,7 @@ class FastMCP(Generic[LifespanResultT]):
mime_type=mime_type,
tags=tags,
enabled=enabled,
- annotations=cast(Annotations | None, annotations),
+ annotations=annotations,
meta=meta,
)
self.add_template(template)
@@ -1737,7 +1742,7 @@ class FastMCP(Generic[LifespanResultT]):
mime_type=mime_type,
tags=tags,
enabled=enabled,
- annotations=cast(Annotations | None, annotations),
+ annotations=annotations,
meta=meta,
)
self.add_resource(resource)
@@ -2582,6 +2587,7 @@ class FastMCP(Generic[LifespanResultT]):
Client[ClientTransportT]
| ClientTransport
| FastMCP[Any]
+ | FastMCP1Server
| AnyUrl
| Path
| MCPConfig
@@ -2624,7 +2630,7 @@ class FastMCP(Generic[LifespanResultT]):
client_factory = fresh_client_factory
else:
- base_client = ProxyClient(backend)
+ base_client = ProxyClient(backend) # type: ignore
# Fresh client created from transport - use fresh sessions per request
def proxy_client_factory():
diff --git a/src/fastmcp/utilities/components.py b/src/fastmcp/utilities/components.py
index 91e0777b0..63ebbaa85 100644
--- a/src/fastmcp/utilities/components.py
+++ b/src/fastmcp/utilities/components.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from collections.abc import Sequence
-from typing import Annotated, Any, TypedDict
+from typing import Annotated, Any, TypedDict, cast
from mcp.types import Icon
from pydantic import BeforeValidator, Field, PrivateAttr
@@ -117,7 +117,7 @@ class FastMCPComponent(FastMCPBaseModel):
copy = super().model_copy(update=update, deep=deep)
if key is not None:
copy._key = key
- return copy
+ return cast(Self, copy)
def __eq__(self, other: object) -> bool:
if type(self) is not type(other):
diff --git a/src/fastmcp/utilities/json_schema.py b/src/fastmcp/utilities/json_schema.py
index 52a897177..b6364757f 100644
--- a/src/fastmcp/utilities/json_schema.py
+++ b/src/fastmcp/utilities/json_schema.py
@@ -98,7 +98,7 @@ def _single_pass_optimize(
if isinstance(node, dict):
# Collect $ref references for unused definition removal
if prune_defs:
- ref = node.get("$ref")
+ ref = node.get("$ref") # type: ignore
if isinstance(ref, str) and ref.startswith("#/$defs/"):
referenced_def = ref.split("/")[-1]
if current_def_name:
@@ -127,13 +127,13 @@ def _single_pass_optimize(
"required",
]
):
- node.pop("title")
+ node.pop("title") # type: ignore
if (
prune_additional_properties
- and node.get("additionalProperties") is False
+ and node.get("additionalProperties") is False # type: ignore
):
- node.pop("additionalProperties")
+ node.pop("additionalProperties") # type: ignore
# Recursive traversal
for key, value in node.items():
diff --git a/src/fastmcp/utilities/mcp_server_config/v1/mcp_server_config.py b/src/fastmcp/utilities/mcp_server_config/v1/mcp_server_config.py
index 1345d7f59..93916079b 100644
--- a/src/fastmcp/utilities/mcp_server_config/v1/mcp_server_config.py
+++ b/src/fastmcp/utilities/mcp_server_config/v1/mcp_server_config.py
@@ -217,7 +217,7 @@ class MCPServerConfig(BaseModel):
"""
if isinstance(v, dict):
return Deployment(**v) # type: ignore[arg-type]
- return cast(Deployment, v)
+ return cast(Deployment, v) # type: ignore[return-value]
@classmethod
def from_file(cls, file_path: Path) -> MCPServerConfig:
diff --git a/src/fastmcp/utilities/openapi.py b/src/fastmcp/utilities/openapi.py
index 0cb242eb7..fa33953d7 100644
--- a/src/fastmcp/utilities/openapi.py
+++ b/src/fastmcp/utilities/openapi.py
@@ -1371,7 +1371,7 @@ def _combine_schemas(route: HTTPRoute) -> dict[str, Any]:
if used_refs:
result["$defs"] = {
name: def_schema
- for name, def_schema in result["$defs"].items()
+ for name, def_schema in result["$defs"].items() # type: ignore[index]
if name in used_refs
}
else:
@@ -1556,7 +1556,7 @@ def extract_output_schema_from_responses(
if used_refs:
output_schema["$defs"] = {
name: def_schema
- for name, def_schema in output_schema["$defs"].items()
+ for name, def_schema in output_schema["$defs"].items() # type: ignore[index]
if name in used_refs
}
else:
diff --git a/tests/client/test_elicitation.py b/tests/client/test_elicitation.py
index 1ad7bcdbf..ba98c2fe4 100644
--- a/tests/client/test_elicitation.py
+++ b/tests/client/test_elicitation.py
@@ -417,9 +417,9 @@ async def test_structured_response_type(
if result.action == "accept":
if isinstance(result.data, dict):
- return f"User: {result.data['name']}, age: {result.data['age']}"
+ return f"User: {result.data['name']}, age: {result.data['age']}" # type: ignore[index]
else:
- return f"User: {result.data.name}, age: {result.data.age}"
+ return f"User: {result.data.name}, age: {result.data.age}" # type: ignore[attr-defined]
return "No user info provided"
async def elicitation_handler(message, response_type, params, ctx):
diff --git a/tests/client/test_streamable_http.py b/tests/client/test_streamable_http.py
index 2cda6bf67..f0378e91c 100644
--- a/tests/client/test_streamable_http.py
+++ b/tests/client/test_streamable_http.py
@@ -29,7 +29,7 @@ def create_test_server() -> FastMCP:
result = await ctx.elicit("What is your name?", response_type=str)
if result.action == "accept":
- return f"You said your name was: {result.data}!" # ty: ignore[possibly-unbound-attribute]
+ return f"You said your name was: {result.data}!" # ty: ignore[possibly-missing-attribute]
else:
return "No name provided"
diff --git a/tests/experimental/openapi_parser/server/openapi/test_openapi_performance.py b/tests/experimental/openapi_parser/server/openapi/test_openapi_performance.py
index 6034e025e..d62ffbbbc 100644
--- a/tests/experimental/openapi_parser/server/openapi/test_openapi_performance.py
+++ b/tests/experimental/openapi_parser/server/openapi/test_openapi_performance.py
@@ -88,7 +88,7 @@ class TestOpenAPIPerformance:
# Generate multiple paths to create a reasonably sized schema
for i in range(100):
path = f"/test/{i}"
- schema["paths"][path] = {
+ schema["paths"][path] = { # type: ignore[index]
"get": {
"operationId": f"test_{i}",
"parameters": [
diff --git a/tests/server/auth/test_oauth_consent_flow.py b/tests/server/auth/test_oauth_consent_flow.py
index 1e001b0f8..85840821b 100644
--- a/tests/server/auth/test_oauth_consent_flow.py
+++ b/tests/server/auth/test_oauth_consent_flow.py
@@ -238,7 +238,11 @@ class TestServerSideStorage:
test_client.cookies.set(k, v)
approval_response = test_client.post(
"/consent",
- data={"action": "approve", "txn": txn_id, "csrf_token": csrf_token},
+ data={
+ "action": "approve",
+ "txn_id": txn_id,
+ "csrf_token": csrf_token if csrf_token else "",
+ },
follow_redirects=False,
)
@@ -641,7 +645,11 @@ class TestConsentSecurity:
c.cookies.set(k, v)
r = c.post(
"/consent/submit",
- data={"action": "approve", "txn_id": txn_id, "csrf_token": csrf},
+ data={
+ "action": "approve",
+ "txn_id": txn_id,
+ "csrf_token": csrf if csrf else "",
+ },
follow_redirects=False,
)
# Extract approved cookie value
diff --git a/tests/server/proxy/test_proxy_client.py b/tests/server/proxy/test_proxy_client.py
index e5414d86e..0bb88c35b 100644
--- a/tests/server/proxy/test_proxy_client.py
+++ b/tests/server/proxy/test_proxy_client.py
@@ -81,7 +81,7 @@ async def proxy_server(fastmcp_server: FastMCP):
"""
A proxy server that forwards interactions with the proxy client to the given fastmcp server.
"""
- return FastMCP.as_proxy(ProxyClient(fastmcp_server))
+ return FastMCP.as_proxy(ProxyClient(fastmcp_server)) # type: ignore
class TestProxyClient:
@@ -367,7 +367,7 @@ class TestProxyClient:
else:
return f"Elicitation {result.action}"
- proxy_server = FastMCP.as_proxy(ProxyClient(fastmcp_server))
+ proxy_server = FastMCP.as_proxy(ProxyClient(fastmcp_server)) # type: ignore
# Test that elicitation works correctly through the proxy
async def elicitation_handler(
diff --git a/tests/test_mcp_config.py b/tests/test_mcp_config.py
index a21b53a98..41924813b 100644
--- a/tests/test_mcp_config.py
+++ b/tests/test_mcp_config.py
@@ -284,7 +284,7 @@ async def test_multi_client_parallel_calls(tmp_path: Path):
exceptions = [result for result in results if isinstance(result, Exception)]
assert len(exceptions) == 0
assert len(results) == 40
- assert all(len(result) == 2 for result in results)
+ assert all(len(result) == 2 for result in results) # type: ignore[arg-type]
@pytest.mark.skipif(
diff --git a/tests/utilities/openapi/test_openapi_fastapi.py b/tests/utilities/openapi/test_openapi_fastapi.py
index 9b7951ec0..7df179aa0 100644
--- a/tests/utilities/openapi/test_openapi_fastapi.py
+++ b/tests/utilities/openapi/test_openapi_fastapi.py
@@ -100,13 +100,14 @@ def fastapi_app() -> FastAPI:
),
):
"""Get details about a specific item."""
+ price = float(item_id) * 10.0
item = {
"id": item_id,
"name": f"Item {item_id}",
- "price": float(item_id) * 10.0,
+ "price": price,
}
if include_tax:
- item["tax"] = item["price"] * 0.2
+ item["tax"] = price * 0.2
return item
@app.put(
diff --git a/tests/utilities/test_json_schema_type.py b/tests/utilities/test_json_schema_type.py
index fc3ccdb84..960a45c9a 100644
--- a/tests/utilities/test_json_schema_type.py
+++ b/tests/utilities/test_json_schema_type.py
@@ -1225,9 +1225,9 @@ class TestNameHandling:
Type = json_schema_to_type(schema)
assert Type.__name__ == "Parent"
child_field_type = get_dataclass_field(Type, "child").type
- assert child_field_type.__origin__ is Union # ty: ignore[possibly-unbound-attribute]
- assert child_field_type.__args__[0].__name__ == "Child" # ty: ignore[possibly-unbound-attribute]
- assert child_field_type.__args__[1] is type(None) # ty: ignore[possibly-unbound-attribute]
+ assert child_field_type.__origin__ is Union # ty: ignore[possibly-missing-attribute]
+ assert child_field_type.__args__[0].__name__ == "Child" # ty: ignore[possibly-missing-attribute]
+ assert child_field_type.__args__[1] is type(None) # ty: ignore[possibly-missing-attribute]
def test_recursive_schema_naming(self):
schema = {
@@ -1240,9 +1240,9 @@ class TestNameHandling:
next_field_type = get_dataclass_field(Type, "next").type
- assert next_field_type.__origin__ is Union # ty: ignore[possibly-unbound-attribute]
- assert next_field_type.__args__[0].__forward_arg__ == "Node" # ty: ignore[possibly-unbound-attribute]
- assert next_field_type.__args__[1] is type(None) # ty: ignore[possibly-unbound-attribute]
+ assert next_field_type.__origin__ is Union # ty: ignore[possibly-missing-attribute]
+ assert next_field_type.__args__[0].__forward_arg__ == "Node" # ty: ignore[possibly-missing-attribute]
+ assert next_field_type.__args__[1] is type(None) # ty: ignore[possibly-missing-attribute]
def test_name_caching_with_different_titles(self):
"""Ensure schemas with different titles create different cached classes"""
diff --git a/uv.lock b/uv.lock
index 10b94ff0d..96f3468ef 100644
--- a/uv.lock
+++ b/uv.lock
@@ -655,7 +655,7 @@ dev = [
{ name = "pytest-timeout", specifier = ">=2.4.0" },
{ name = "pytest-xdist", specifier = ">=3.6.1" },
{ name = "ruff", specifier = ">=0.12.8" },
- { name = "ty", specifier = "==0.0.1a19" },
+ { name = "ty", specifier = "==0.0.1a25" },
]
[[package]]
@@ -2069,27 +2069,27 @@ wheels = [
[[package]]
name = "ty"
-version = "0.0.1a19"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/c0/04/281c1a3c9c53dae5826b9d01a3412de653e3caf1ca50ce1265da66e06d73/ty-0.0.1a19.tar.gz", hash = "sha256:894f6a13a43989c8ef891ae079b3b60a0c0eae00244abbfbbe498a3840a235ac", size = 4098412, upload-time = "2025-08-19T13:29:58.559Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/3e/65/a61cfcc7248b0257a3110bf98d3d910a4729c1063abdbfdcd1cad9012323/ty-0.0.1a19-py3-none-linux_armv6l.whl", hash = "sha256:e0e7762f040f4bab1b37c57cb1b43cc3bc5afb703fa5d916dfcafa2ef885190e", size = 8143744, upload-time = "2025-08-19T13:29:13.88Z" },
- { url = "https://files.pythonhosted.org/packages/02/d9/232afef97d9afa2274d23a4c49a3ad690282ca9696e1b6bbb6e4e9a1b072/ty-0.0.1a19-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cd0a67ac875f49f34d9a0b42dcabf4724194558a5dd36867209d5695c67768f7", size = 8305799, upload-time = "2025-08-19T13:29:17.322Z" },
- { url = "https://files.pythonhosted.org/packages/20/14/099d268da7a9cccc6ba38dfc124f6742a1d669bc91f2c61a3465672b4f71/ty-0.0.1a19-py3-none-macosx_11_0_arm64.whl", hash = "sha256:ff8b1c0b85137333c39eccd96c42603af8ba7234d6e2ed0877f66a4a26750dd4", size = 7901431, upload-time = "2025-08-19T13:29:21.635Z" },
- { url = "https://files.pythonhosted.org/packages/c2/cd/3f1ca6e1d7f77cc4d08910a3fc4826313c031c0aae72286ae859e737670c/ty-0.0.1a19-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4fef34a29f4b97d78aa30e60adbbb12137cf52b8b2b0f1a408dd0feb0466908a", size = 8051501, upload-time = "2025-08-19T13:29:23.741Z" },
- { url = "https://files.pythonhosted.org/packages/47/72/ddbec39f48ce3f5f6a3fa1f905c8fff2873e59d2030f738814032bd783e3/ty-0.0.1a19-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b0f219cb43c0c50fc1091f8ebd5548d3ef31ee57866517b9521d5174978af9fd", size = 7981234, upload-time = "2025-08-19T13:29:25.839Z" },
- { url = "https://files.pythonhosted.org/packages/f2/0f/58e76b8d4634df066c790d362e8e73b25852279cd6f817f099b42a555a66/ty-0.0.1a19-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22abb6c1f14c65c1a2fafd38e25dd3c87994b3ab88cb0b323235b51dbad082d9", size = 8916394, upload-time = "2025-08-19T13:29:27.932Z" },
- { url = "https://files.pythonhosted.org/packages/70/30/01bfd93ccde11540b503e2539e55f6a1fc6e12433a229191e248946eb753/ty-0.0.1a19-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5b49225c349a3866e38dd297cb023a92d084aec0e895ed30ca124704bff600e6", size = 9412024, upload-time = "2025-08-19T13:29:30.942Z" },
- { url = "https://files.pythonhosted.org/packages/a8/a2/2216d752f5f22c5c0995f9b13f18337301220f2a7d952c972b33e6a63583/ty-0.0.1a19-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:88f41728b3b07402e0861e3c34412ca963268e55f6ab1690208f25d37cb9d63c", size = 9032657, upload-time = "2025-08-19T13:29:33.933Z" },
- { url = "https://files.pythonhosted.org/packages/24/c7/e6650b0569be1b69a03869503d07420c9fb3e90c9109b09726c44366ce63/ty-0.0.1a19-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33814a1197ec3e930fcfba6fb80969fe7353957087b42b88059f27a173f7510b", size = 8812775, upload-time = "2025-08-19T13:29:36.505Z" },
- { url = "https://files.pythonhosted.org/packages/35/c6/b8a20e06b97fe8203059d56d8f91cec4f9633e7ba65f413d80f16aa0be04/ty-0.0.1a19-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d71b7f2b674a287258f628acafeecd87691b169522945ff6192cd8a69af15857", size = 8631417, upload-time = "2025-08-19T13:29:38.837Z" },
- { url = "https://files.pythonhosted.org/packages/be/99/821ca1581dcf3d58ffb7bbe1cde7e1644dbdf53db34603a16a459a0b302c/ty-0.0.1a19-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3a7f8ef9ac4c38e8651c18c7380649c5a3fa9adb1a6012c721c11f4bbdc0ce24", size = 7928900, upload-time = "2025-08-19T13:29:41.08Z" },
- { url = "https://files.pythonhosted.org/packages/08/cb/59f74a0522e57565fef99e2287b2bc803ee47ff7dac250af26960636939f/ty-0.0.1a19-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:60f40e72f0fbf4e54aa83d9a6cb1959f551f83de73af96abbb94711c1546bd60", size = 8003310, upload-time = "2025-08-19T13:29:43.165Z" },
- { url = "https://files.pythonhosted.org/packages/4c/b3/1209b9acb5af00a2755114042e48fb0f71decc20d9d77a987bf5b3d1a102/ty-0.0.1a19-py3-none-musllinux_1_2_i686.whl", hash = "sha256:64971e4d3e3f83dc79deb606cc438255146cab1ab74f783f7507f49f9346d89d", size = 8496463, upload-time = "2025-08-19T13:29:46.136Z" },
- { url = "https://files.pythonhosted.org/packages/a2/d6/a4b6ba552d347a08196d83a4d60cb23460404a053dd3596e23a922bce544/ty-0.0.1a19-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:9aadbff487e2e1486e83543b4f4c2165557f17432369f419be9ba48dc47625ca", size = 8700633, upload-time = "2025-08-19T13:29:49.351Z" },
- { url = "https://files.pythonhosted.org/packages/96/c5/258f318d68b95685c8d98fb654a38882c9d01ce5d9426bed06124f690f04/ty-0.0.1a19-py3-none-win32.whl", hash = "sha256:00b75b446357ee22bcdeb837cb019dc3bc1dc5e5013ff0f46a22dfe6ce498fe2", size = 7811441, upload-time = "2025-08-19T13:29:52.077Z" },
- { url = "https://files.pythonhosted.org/packages/fb/bb/039227eee3c0c0cddc25f45031eea0f7f10440713f12d333f2f29cf8e934/ty-0.0.1a19-py3-none-win_amd64.whl", hash = "sha256:aaef76b2f44f6379c47adfe58286f0c56041cb2e374fd8462ae8368788634469", size = 8441186, upload-time = "2025-08-19T13:29:54.53Z" },
- { url = "https://files.pythonhosted.org/packages/74/5f/bceb29009670ae6f759340f9cb434121bc5ed84ad0f07bdc6179eaaa3204/ty-0.0.1a19-py3-none-win_arm64.whl", hash = "sha256:893755bb35f30653deb28865707e3b16907375c830546def2741f6ff9a764710", size = 8000810, upload-time = "2025-08-19T13:29:56.796Z" },
+version = "0.0.1a25"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/f6/6b/e73bc3c1039ea72936158a08313155a49e5aa5e7db5205a149fe516a4660/ty-0.0.1a25.tar.gz", hash = "sha256:5550b24b9dd0e0f8b4b2c1f0fcc608a55d0421dd67b6c364bc7bf25762334511", size = 4403670, upload-time = "2025-10-29T19:40:23.647Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/8f/3b/4457231238a2eeb04cba4ba7cc33d735be68ee46ca40a98ae30e187de864/ty-0.0.1a25-py3-none-linux_armv6l.whl", hash = "sha256:d35b2c1f94a014a22875d2745aa0432761d2a9a8eb7212630d5caf547daeef6d", size = 8878803, upload-time = "2025-10-29T19:39:42.243Z" },
+ { url = "https://files.pythonhosted.org/packages/8a/fa/a328713dd310018fc7a381693d8588185baa2fdae913e01a6839187215df/ty-0.0.1a25-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:192edac94675a468bac7f6e04687a77a64698e4e1fe01f6a048bf9b6dde5b703", size = 8695667, upload-time = "2025-10-29T19:39:45.179Z" },
+ { url = "https://files.pythonhosted.org/packages/22/e8/5707939118992ced2bf5385adc3ede7723c1b717b07ad14c495eea1e47b4/ty-0.0.1a25-py3-none-macosx_11_0_arm64.whl", hash = "sha256:949523621f336e01bc7d687b7bd08fe838edadbdb6563c2c057ed1d264e820cf", size = 8159012, upload-time = "2025-10-29T19:39:47.011Z" },
+ { url = "https://files.pythonhosted.org/packages/eb/fb/ff313aa71602225cd78f1bce3017713d6d1b1c1e0fa8101ead4594a60d95/ty-0.0.1a25-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94f78f621458c05e59e890061021198197f29a7b51a33eda82bbb036e7ed73d7", size = 8433675, upload-time = "2025-10-29T19:39:48.443Z" },
+ { url = "https://files.pythonhosted.org/packages/c0/8d/cc7e7fb57215a15b575a43ed042bdd92971871e0decec1b26d2e7d969465/ty-0.0.1a25-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d9656fca8062a2c6709c30d76d662c96d2e7dbfee8f70e55ec6b6afd67b5d447", size = 8668456, upload-time = "2025-10-29T19:39:50.412Z" },
+ { url = "https://files.pythonhosted.org/packages/b8/6d/d7bf5909ed2dcdcbc1e2ca7eea80929893e2d188d9c36b3fcb2b36532ff6/ty-0.0.1a25-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9f3bbf523b49935bbd76e230408d858dce0d614f44f5807bbbd0954f64e0f01", size = 9023543, upload-time = "2025-10-29T19:39:52.292Z" },
+ { url = "https://files.pythonhosted.org/packages/b4/b8/72bcefb4be32e5a84f0b21de2552f16cdb4cae3eb271ac891c8199c26b1a/ty-0.0.1a25-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:f13ea9815f4a54a0a303ca7bf411b0650e3c2a24fc6c7889ffba2c94f5e97a6a", size = 9700013, upload-time = "2025-10-29T19:39:57.283Z" },
+ { url = "https://files.pythonhosted.org/packages/90/0d/cf7e794b840cf6b0bbecb022e593c543f85abad27a582241cf2095048cb1/ty-0.0.1a25-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eab6e33ebe202a71a50c3d5a5580e3bc1a85cda3ffcdc48cec3f1c693b7a873b", size = 9372574, upload-time = "2025-10-29T19:40:04.532Z" },
+ { url = "https://files.pythonhosted.org/packages/1e/71/2d35e7d51b48eabd330e2f7b7e0bce541cbd95950c4d2f780e85f3366af1/ty-0.0.1a25-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f6b9a31da43424cdab483703a54a561b93aabba84630788505329fc5294a9c62", size = 9535726, upload-time = "2025-10-29T19:40:06.548Z" },
+ { url = "https://files.pythonhosted.org/packages/57/d3/01ecc23bbd8f3e0dfbcf9172d06d84e88155c5f416f1491137e8066fd859/ty-0.0.1a25-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0a90d897a7c1a5ae9b41a4c7b0a42262a06361476ad88d783dbedd7913edadbc", size = 9003380, upload-time = "2025-10-29T19:40:08.683Z" },
+ { url = "https://files.pythonhosted.org/packages/de/f9/cde9380d8a1a6ca61baeb9aecb12cbec90d489aa929be55cd78ad5c2ccd9/ty-0.0.1a25-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:93c7e7ab2859af0f866d34d27f4ae70dd4fb95b847387f082de1197f9f34e068", size = 8401833, upload-time = "2025-10-29T19:40:10.627Z" },
+ { url = "https://files.pythonhosted.org/packages/0b/39/0acf3625b0c495011795a391016b572f97a812aca1d67f7a76621fdb9ebf/ty-0.0.1a25-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:4a247061bd32bae3865a236d7f8b6c9916c80995db30ae1600999010f90623a9", size = 8706761, upload-time = "2025-10-29T19:40:12.575Z" },
+ { url = "https://files.pythonhosted.org/packages/25/73/7de1648f3563dd9d416d36ab5f1649bfd7b47a179135027f31d44b89a246/ty-0.0.1a25-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1711dd587eccf04fd50c494dc39babe38f4cb345bc3901bf1d8149cac570e979", size = 8792426, upload-time = "2025-10-29T19:40:14.553Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/8a/b6e761a65eac7acd10b2e452f49b2d8ae0ea163ca36bb6b18b2dadae251b/ty-0.0.1a25-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5f4c9b0cf7995e2e3de9bab4d066063dea92019f2f62673b7574e3612643dd35", size = 9103991, upload-time = "2025-10-29T19:40:16.332Z" },
+ { url = "https://files.pythonhosted.org/packages/e4/25/9324ae947fcc4322470326cf8276a3fc2f08dc82adec1de79d963fdf7af5/ty-0.0.1a25-py3-none-win32.whl", hash = "sha256:168fc8aee396d617451acc44cd28baffa47359777342836060c27aa6f37e2445", size = 8387095, upload-time = "2025-10-29T19:40:18.368Z" },
+ { url = "https://files.pythonhosted.org/packages/3b/2b/cb12cbc7db1ba310aa7b1de9b4e018576f653105993736c086ee67d2ec02/ty-0.0.1a25-py3-none-win_amd64.whl", hash = "sha256:a2fad3d8e92bb4d57a8872a6f56b1aef54539d36f23ebb01abe88ac4338efafb", size = 9059225, upload-time = "2025-10-29T19:40:20.278Z" },
+ { url = "https://files.pythonhosted.org/packages/2f/c1/f6be8cdd0bf387c1d8ee9d14bb299b7b5d2c0532f550a6693216a32ec0c5/ty-0.0.1a25-py3-none-win_arm64.whl", hash = "sha256:dde2962d448ed87c48736e9a4bb13715a4cced705525e732b1c0dac1d4c66e3d", size = 8536832, upload-time = "2025-10-29T19:40:22.014Z" },
]
[[package]]