From 3f077bbb2b6455790e7c30cd4f1053559fd77c13 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Fri, 17 Oct 2025 16:26:54 +0200 Subject: [PATCH] Make sure that cached values from links_and_reverse_links_dict are not mutable inside Yay python, it's great... In 20b45bad3cb00c3a366f3adaf460edcb68a45d58 we made sure that we'd return read only dicts from this function since it's caching the result, but we kinda forgot that the value was a set and thus was still mutable... This commits freezes said sets so now those objects should be properly read only... --- src/taskgraph/graph.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/taskgraph/graph.py b/src/taskgraph/graph.py index d54d3b389..a8662eece 100644 --- a/src/taskgraph/graph.py +++ b/src/taskgraph/graph.py @@ -133,7 +133,11 @@ def links_and_reverse_links_dict(self): for left, right, _ in self.edges: forward[left].add(right) reverse[right].add(left) - return (ReadOnlyDict(forward), ReadOnlyDict(reverse)) + + return ( + ReadOnlyDict({key: frozenset(value) for key, value in forward.items()}), + ReadOnlyDict({key: frozenset(value) for key, value in reverse.items()}), + ) def links_dict(self): """