From 53d183e0f5eaae13222c646b49758ad5847f9323 Mon Sep 17 00:00:00 2001 From: abhishekmadan30 Date: Wed, 11 Feb 2026 15:57:00 -0500 Subject: [PATCH] fix: loosen constraints on optionally_keyed_by for msgspec --- src/taskgraph/util/schema.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/taskgraph/util/schema.py b/src/taskgraph/util/schema.py index 9f256f69d..7d4e3cc3e 100644 --- a/src/taskgraph/util/schema.py +++ b/src/taskgraph/util/schema.py @@ -6,7 +6,7 @@ import re from collections.abc import Mapping from functools import reduce -from typing import Literal, Optional, Union +from typing import Any, Literal, Optional, Union import msgspec import voluptuous @@ -79,9 +79,11 @@ def optionally_keyed_by(*arguments, use_msgspec=False): if use_msgspec: # msgspec implementation - return type hints _type = arguments[-1] + if _type is object: + return object fields = arguments[:-1] bykeys = [Literal[f"by-{field}"] for field in fields] - return Union[_type, dict[UnionTypes(*bykeys), dict[str, _type]]] + return Union[_type, dict[UnionTypes(*bykeys), dict[str, Any]]] else: # voluptuous implementation - return validator function schema = arguments[-1]