From bc4fd6a39b753cfd6da65a5ed0866475f66821be Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:08:00 +0000 Subject: [PATCH] fix: resolve circular import in CLI authentication module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move ToolCommand import to be local inside _poll_for_token method - Update test mock to patch ToolCommand at correct location - Resolves Python 3.11 test collection failure in CI Co-Authored-By: João --- src/crewai/cli/authentication/main.py | 3 +-- tests/cli/authentication/test_auth_main.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/crewai/cli/authentication/main.py b/src/crewai/cli/authentication/main.py index 5a335e1f2..12308e3f1 100644 --- a/src/crewai/cli/authentication/main.py +++ b/src/crewai/cli/authentication/main.py @@ -5,8 +5,6 @@ from typing import Any, Dict import requests from rich.console import Console -from crewai.cli.tools.main import ToolCommand - from .constants import AUTH0_AUDIENCE, AUTH0_CLIENT_ID, AUTH0_DOMAIN from .utils import TokenManager, validate_token @@ -67,6 +65,7 @@ class AuthenticationCommand: self.token_manager.save_tokens(token_data["access_token"], expires_in) try: + from crewai.cli.tools.main import ToolCommand ToolCommand().login() except Exception: console.print( diff --git a/tests/cli/authentication/test_auth_main.py b/tests/cli/authentication/test_auth_main.py index a0b4fa0d9..5d11d2421 100644 --- a/tests/cli/authentication/test_auth_main.py +++ b/tests/cli/authentication/test_auth_main.py @@ -44,7 +44,7 @@ class TestAuthenticationCommand(unittest.TestCase): mock_print.assert_any_call("2. Enter the following code: ", "ABCDEF") mock_open.assert_called_once_with("https://example.com") - @patch("crewai.cli.authentication.main.ToolCommand") + @patch("crewai.cli.tools.main.ToolCommand") @patch("crewai.cli.authentication.main.requests.post") @patch("crewai.cli.authentication.main.validate_token") @patch("crewai.cli.authentication.main.console.print")