From dad4b399427ee5869bdfefa941d153bdfef5fdfb Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 8 Jun 2025 07:11:48 +0000 Subject: [PATCH] Fix lint and type check errors in console formatter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace bare except with specific Exception handler - Add proper type annotations for _spinning_branches and _spinner_timer - Fix timer assignment logic to handle None type properly Co-Authored-By: João --- .../utilities/events/utils/console_formatter.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/crewai/utilities/events/utils/console_formatter.py b/src/crewai/utilities/events/utils/console_formatter.py index 6cece7a8d..decd6a32a 100644 --- a/src/crewai/utilities/events/utils/console_formatter.py +++ b/src/crewai/utilities/events/utils/console_formatter.py @@ -70,8 +70,8 @@ class ConsoleFormatter: self.console = Console(width=None) self.verbose = verbose self.spinner = SimpleSpinner() - self._spinning_branches = {} # Track which branches are spinning - self._spinner_timer = None + self._spinning_branches: Dict[int, Dict[str, Any]] = {} # Track which branches are spinning + self._spinner_timer: Optional[threading.Timer] = None # Live instance to dynamically update a Tree renderable (e.g. the Crew tree) # When multiple Tree objects are printed sequentially we reuse this Live # instance so the previous render is replaced instead of writing a new one. @@ -1392,11 +1392,13 @@ class ConsoleFormatter: self.print(tree_to_show) # Schedule next update - self._spinner_timer = threading.Timer(0.2, update_spinners) - self._spinner_timer.start() + timer = threading.Timer(0.2, update_spinners) + self._spinner_timer = timer + timer.start() - self._spinner_timer = threading.Timer(0.2, update_spinners) - self._spinner_timer.start() + timer = threading.Timer(0.2, update_spinners) + self._spinner_timer = timer + timer.start() def cleanup(self) -> None: """Clean up resources including stopping any running timers.""" @@ -1411,5 +1413,5 @@ class ConsoleFormatter: """Destructor to ensure cleanup on object deletion.""" try: self.cleanup() - except: + except Exception: pass # Ignore errors during cleanup