[PATCH 10/26] lucid: use typing.List for Python 3.8 compat
Daniel Gomez <[email protected]> Tue, 19 May 2026 15:28:07 +0200
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> The plugin's DOCUMENTATION block advertises Python 3.8+ support, but its instance-attribute annotations used PEP 585 subscripted builtins (list[str], list[dict]) that are only parseable at runtime on Python 3.9 and later. The file carries from __future__ import annotations, so normal execution is fine on 3.8 because annotations are stored as strings, but tooling that imports and evaluates annotations (ansible- doc at higher verbosity, strict linters, runtime introspection) will still raise on those forms. Import List from typing and rewrite the three annotations affected (current_task_hosts, play_hosts, failed_items) to use List so the annotations are honest across every interpreter version the plugin claims to support. Suggested-by: Chuck Lever <[email protected]> Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- callback_plugins/lucid.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/callback_plugins/lucid.py b/callback_plugins/lucid.py index 6bd822a3..6e678932 100644 --- a/callback_plugins/lucid.py +++ b/callback_plugins/lucid.py @@ -19,7 +19,7 @@ import sys import time import threading from datetime import datetime -from typing import Dict, Tuple, Optional, Any +from typing import Dict, List, Tuple, Optional, Any from collections import deque from ansible.plugins.callback import CallbackBase @@ -96,8 +96,8 @@ class CallbackModule(CallbackBase): ) # (host, task_uuid) -> task_info self.completed_tasks = deque(maxlen=3) # Keep last 3 completed self.current_task_name: str = "" - self.current_task_hosts: list[str] = [] - self.play_hosts: list[str] = [] # All hosts in current play + self.current_task_hosts: List[str] = [] + self.play_hosts: List[str] = [] # All hosts in current play self.pending_play_header: Optional[str] = None # Deferred play banner self.current_play_name: str = "" # Current play name for dynamic display @@ -111,7 +111,7 @@ class CallbackModule(CallbackBase): self.task_lock = threading.Lock() # Failed loop items for display on task failure - self.failed_items: list[dict] = [] + self.failed_items: List[dict] = [] # Will be set in set_options() self.output_mode = "auto" -- 2.53.0