From 7b9dc8239a8e988194653eae5f8ee3a7dd1497bd Mon Sep 17 00:00:00 2001 From: adnanhd Date: Mon, 15 Jun 2026 08:02:05 +0300 Subject: [PATCH] fix: make package import on Python 3.8 - convert two module-level type aliases (ObserveTargets/ReporterMethods) from PEP 585 tuple[...] to typing.Tuple; the RHS is evaluated at import - import Callable from typing where it builds Handler / ContextHandler aliases at runtime (collections.abc generics are 3.9+) --- eventforge/observers.py | 4 ++-- eventforge/queue.py | 6 ++++-- eventforge/task.py | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/eventforge/observers.py b/eventforge/observers.py index b6eebcc..2be4430 100644 --- a/eventforge/observers.py +++ b/eventforge/observers.py @@ -721,8 +721,8 @@ def _register_class_subscriber( # Each entry: (attr_name, ((target_cls, event), ...)) -- the @observe targets # placed on the Reporter method. -ObserveTargets = tuple[tuple[type, str], ...] -ReporterMethods = tuple[tuple[str, ObserveTargets], ...] +ObserveTargets = Tuple[Tuple[type, str], ...] +ReporterMethods = Tuple[Tuple[str, ObserveTargets], ...] _REPORTER_OBSERVE_METHODS: weakref.WeakKeyDictionary[type, ReporterMethods] = ( weakref.WeakKeyDictionary() diff --git a/eventforge/queue.py b/eventforge/queue.py index cf0dadc..617bc86 100644 --- a/eventforge/queue.py +++ b/eventforge/queue.py @@ -17,8 +17,10 @@ from __future__ import annotations import threading -from collections.abc import Callable -from typing import Any, Dict, List, Optional, Tuple, Union, overload + +# ``Callable`` is subscripted at runtime in the Handler aliases below; the +# typing alias is required on Python 3.8 (collections.abc generics are 3.9+). +from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload from uuid import uuid4 from eventforge.observers import BroadcastDispatcher, Dispatcher, Eventful, Observable diff --git a/eventforge/task.py b/eventforge/task.py index d716add..aacfb60 100644 --- a/eventforge/task.py +++ b/eventforge/task.py @@ -6,8 +6,10 @@ import logging import threading import time -from collections.abc import Callable -from typing import Any, Dict, List, Optional, Protocol, Tuple, cast + +# ``Callable`` is subscripted at runtime in the ContextHandler alias below; the +# typing alias is required on Python 3.8 (collections.abc generics are 3.9+). +from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, cast from uuid import uuid4 from eventforge.executor import ExecutionMode, Executor