From 0779e95d89ac370323975cfe5084c4dec6d2b073 Mon Sep 17 00:00:00 2001 From: Yun Zheng Hu Date: Tue, 17 Jun 2025 11:23:09 +0000 Subject: [PATCH] Add __getattr__ typing hints to Record class This improves support for type checkers when using Records. --- flow/record/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flow/record/base.py b/flow/record/base.py index 47945d5c..cb43039d 100644 --- a/flow/record/base.py +++ b/flow/record/base.py @@ -185,6 +185,9 @@ def _asdict(self, fields: list[str] | None = None, exclude: list[str] | None = N return OrderedDict((k, getattr(self, k)) for k in fields if k in self.__slots__ and k not in exclude) return OrderedDict((k, getattr(self, k)) for k in self.__slots__ if k not in exclude) + if TYPE_CHECKING: + def __getattr__(self, name: str) -> Any: ... + def __setattr__(self, k: str, v: Any) -> None: """Enforce setting the fields to their respective types.""" # NOTE: This is a HOT code path