From 29f3bbb788cfeca582578260cb48c5472163b7bc Mon Sep 17 00:00:00 2001 From: Arnaud Gelas Date: Sat, 8 Jun 2024 15:40:06 +0200 Subject: [PATCH] Fix all pre-commit errors When running pre-commit run --all-files src/crewai/__init__.py:1:26: F401 `crewai.agent.Agent` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/__init__.py:2:25: F401 `crewai.crew.Crew` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/__init__.py:3:28: F401 `crewai.process.Process` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/__init__.py:4:25: F401 `crewai.task.Task` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/agents/__init__.py:1:34: F401 `.cache.cache_handler.CacheHandler` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/agents/__init__.py:2:23: F401 `.executor.CrewAgentExecutor` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/agents/__init__.py:3:21: F401 `.parser.CrewAgentParser` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/agents/__init__.py:4:28: F401 `.tools_handler.ToolsHandler` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/agents/cache/__init__.py:1:28: F401 `.cache_handler.CacheHandler` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/memory/__init__.py:1:35: F401 `.entity.entity_memory.EntityMemory` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/memory/__init__.py:2:41: F401 `.long_term.long_term_memory.LongTermMemory` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/memory/__init__.py:3:43: F401 `.short_term.short_term_memory.ShortTermMemory` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/project/__init__.py:1:26: F401 `.annotations.agent` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/project/__init__.py:1:33: F401 `.annotations.crew` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/project/__init__.py:1:39: F401 `.annotations.task` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/project/__init__.py:2:24: F401 `.crew_base.CrewBase` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/telemetry/__init__.py:1:24: F401 `.telemetry.Telemetry` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:1:24: F401 `.converter.Converter` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:1:35: F401 `.converter.ConverterError` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:2:19: F401 `.i18n.I18N` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:3:25: F401 `.instructor.Instructor` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:4:21: F401 `.logger.Logger` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:5:22: F401 `.printer.Printer` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:6:22: F401 `.prompts.Prompts` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:7:29: F401 `.rpm_controller.RPMController` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:8:26: F401 `.fileHandler.FileHandler` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/__init__.py:9:21: F401 `.parser.YamlParser` imported but unused; consider removing, adding to `__all__`, or using a redundant alias src/crewai/utilities/logger.py:16:25: F821 Undefined name `datetime` --- src/crewai/__init__.py | 1 + src/crewai/agents/__init__.py | 1 + src/crewai/agents/cache/__init__.py | 1 + src/crewai/memory/__init__.py | 1 + src/crewai/project/__init__.py | 1 + src/crewai/telemetry/__init__.py | 1 + src/crewai/utilities/__init__.py | 12 ++++++++++++ src/crewai/utilities/fileHandler.py | 2 +- src/crewai/utilities/logger.py | 1 - tests/agent_tools/agent_tools_test.py | 2 ++ tests/memory/short_term_memory_test.py | 5 +---- 11 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/crewai/__init__.py b/src/crewai/__init__.py index 47a761f117..186b5039ac 100644 --- a/src/crewai/__init__.py +++ b/src/crewai/__init__.py @@ -1,3 +1,4 @@ +__all__ = ["Agent", "Crew", "Process", "Task"] from crewai.agent import Agent from crewai.crew import Crew from crewai.process import Process diff --git a/src/crewai/agents/__init__.py b/src/crewai/agents/__init__.py index 2bcc6f28a6..82c21d53f8 100644 --- a/src/crewai/agents/__init__.py +++ b/src/crewai/agents/__init__.py @@ -1,3 +1,4 @@ +__all__ = ["CacheHandler", "CrewAgentExecutor", "CrewAgentParser", "ToolsHandler"] from .cache.cache_handler import CacheHandler from .executor import CrewAgentExecutor from .parser import CrewAgentParser diff --git a/src/crewai/agents/cache/__init__.py b/src/crewai/agents/cache/__init__.py index c91d30c8b4..6065274e34 100644 --- a/src/crewai/agents/cache/__init__.py +++ b/src/crewai/agents/cache/__init__.py @@ -1 +1,2 @@ +__all__ = ["CacheHandler"] from .cache_handler import CacheHandler diff --git a/src/crewai/memory/__init__.py b/src/crewai/memory/__init__.py index 91d4db9e84..03eac00375 100644 --- a/src/crewai/memory/__init__.py +++ b/src/crewai/memory/__init__.py @@ -1,3 +1,4 @@ +__all__ = ["EntityMemory", "LongTermMemory", "ShortTermMemory"] from .entity.entity_memory import EntityMemory from .long_term.long_term_memory import LongTermMemory from .short_term.short_term_memory import ShortTermMemory diff --git a/src/crewai/project/__init__.py b/src/crewai/project/__init__.py index 25326a2af5..97376c8b96 100644 --- a/src/crewai/project/__init__.py +++ b/src/crewai/project/__init__.py @@ -1,2 +1,3 @@ +__all__ = ["agent", "crew", "task", "CrewBase"] from .annotations import agent, crew, task from .crew_base import CrewBase diff --git a/src/crewai/telemetry/__init__.py b/src/crewai/telemetry/__init__.py index 6caed962a2..fbd1270b3e 100644 --- a/src/crewai/telemetry/__init__.py +++ b/src/crewai/telemetry/__init__.py @@ -1 +1,2 @@ +__all__ = ["Telemetry"] from .telemetry import Telemetry diff --git a/src/crewai/utilities/__init__.py b/src/crewai/utilities/__init__.py index e21c4815b6..ccbf6960ed 100644 --- a/src/crewai/utilities/__init__.py +++ b/src/crewai/utilities/__init__.py @@ -1,3 +1,15 @@ +__all__ = [ + "Converter", + "ConverterError", + "I18N", + "Instructor", + "Logger", + "Printer", + "Prompts", + "RPMController", + "FileHandler", + "YamlParser", +] from .converter import Converter, ConverterError from .i18n import I18N from .instructor import Instructor diff --git a/src/crewai/utilities/fileHandler.py b/src/crewai/utilities/fileHandler.py index 9d2d1fa23b..bf5c2180b9 100644 --- a/src/crewai/utilities/fileHandler.py +++ b/src/crewai/utilities/fileHandler.py @@ -16,5 +16,5 @@ def __init__(self, file_path): def log(self, **kwargs): now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") message = f"{now}: ".join([f"{key}={value}" for key, value in kwargs.items()]) - with open(self._path, "a", encoding = 'utf-8') as file: + with open(self._path, "a", encoding="utf-8") as file: file.write(message + "\n") diff --git a/src/crewai/utilities/logger.py b/src/crewai/utilities/logger.py index 55eeb02cc6..0e19ee5e12 100644 --- a/src/crewai/utilities/logger.py +++ b/src/crewai/utilities/logger.py @@ -1,6 +1,5 @@ from datetime import datetime from crewai.utilities.printer import Printer -from datetime import datetime class Logger: diff --git a/tests/agent_tools/agent_tools_test.py b/tests/agent_tools/agent_tools_test.py index a5914c6627..85ec260a99 100644 --- a/tests/agent_tools/agent_tools_test.py +++ b/tests/agent_tools/agent_tools_test.py @@ -55,6 +55,7 @@ def test_ask_question(): == "As an AI researcher, I don't have personal feelings or emotions like love or hate. However, I recognize the importance of AI Agents in today's technological landscape. They have the potential to greatly enhance our lives and make tasks more efficient. At the same time, it is crucial to consider the ethical implications and societal impacts that come with their use. My role is to provide objective research and analysis on these topics." ) + @pytest.mark.vcr(filter_headers=["authorization"]) def test_ask_question_with_wrong_co_worker_variable(): result = tools.ask_question( @@ -68,6 +69,7 @@ def test_ask_question_with_wrong_co_worker_variable(): == "No, I don't hate AI agents. In fact, I find them quite fascinating. They are powerful tools that can greatly assist in various tasks, including my research. As a technology researcher, AI and AI agents are subjects of interest to me due to their potential in advancing our understanding and capabilities in various fields. My supposed love for them stems from this professional interest and the potential they hold." ) + @pytest.mark.vcr(filter_headers=["authorization"]) def test_delegate_work_withwith_coworker_as_array(): result = tools.delegate_work( diff --git a/tests/memory/short_term_memory_test.py b/tests/memory/short_term_memory_test.py index fa8cc41f95..f487a9cfc5 100644 --- a/tests/memory/short_term_memory_test.py +++ b/tests/memory/short_term_memory_test.py @@ -23,10 +23,7 @@ def short_term_memory(): expected_output="A list of relevant URLs based on the search query.", agent=agent, ) - return ShortTermMemory(crew=Crew( - agents=[agent], - tasks=[task] - )) + return ShortTermMemory(crew=Crew(agents=[agent], tasks=[task])) @pytest.mark.vcr(filter_headers=["authorization"])