Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(hogql): read runner annotations from the class (#104733)

Raúl Negrón-Oteroe90e87238bdc
diff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.py
index 330cf2574d62..b6df12bc6485 100644
--- a/posthog/hogql_queries/query_runner.py
+++ b/posthog/hogql_queries/query_runner.py
@@ -1,3 +1,4 @@
+import inspect
import threading
from abc import ABC, abstractmethod
from collections.abc import Callable, Sequence
@@ -1835,13 +1836,21 @@ class QueryRunner(ABC, Generic[Q, R, CR]):
Prints against the shared database so the printer does not build a second one."""
return to_printed_hogql(query, self.team, database=self.shared_database)
+ def _class_annotation(self, name: str) -> Any:
+ # Python 3.14 instances no longer expose their class's `__annotations__` (PEP 649).
+ for cls in type(self).__mro__:
+ annotations = inspect.get_annotations(cls)
+ if name in annotations:
+ return annotations[name]
+ raise KeyError(name)
+
@property
def query_type(self) -> Any:
- return self.__annotations__["query"] # Enforcing the type annotation of `query` at runtime
+ return self._class_annotation("query") # Enforcing the type annotation of `query` at runtime
@property
def cached_response_type(self) -> type[CR]:
- return self.__annotations__["cached_response"]
+ return self._class_annotation("cached_response")
def is_query_node(self, data) -> TypeGuard[Q]:
query_type: Any = self.query_type