From 5fbd4d3c1d43a29d088e9d6ab3fd38052d3b4f5d Mon Sep 17 00:00:00 2001 From: Itamar Oren Date: Mon, 9 Feb 2026 20:27:57 -0800 Subject: [PATCH] Use default_factory for mutable dataclass default (#43) Summary: Python 3.12 strictly enforces that dataclass fields with mutable defaults (including other dataclass instances) must use field(default_factory=...) instead of direct assignment. Changed the ApplicationClockInfo default to use a lambda factory. Reviewed By: drinkmorewaterr Differential Revision: D92669096 --- gcm/tests/test_nvml_monitor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcm/tests/test_nvml_monitor.py b/gcm/tests/test_nvml_monitor.py index 2a10258..3fcf837 100644 --- a/gcm/tests/test_nvml_monitor.py +++ b/gcm/tests/test_nvml_monitor.py @@ -156,8 +156,10 @@ class IteratorFakeGPUDevice: power_limit: int retired_pages_double_bit_ecc_error: List[int] retired_pages_multiple_single_bit_ecc_errors: List[int] - application_clock_info: ApplicationClockInfo = ApplicationClockInfo( - graphics_freq=1155, memory_freq=1593 + application_clock_info: ApplicationClockInfo = field( + default_factory=lambda: ApplicationClockInfo( + graphics_freq=1155, memory_freq=1593 + ) ) def get_compute_processes(self) -> List[ProcessInfo]: