From 86ecf525e3ef9f80e1dbb32dca1defd6082607d7 Mon Sep 17 00:00:00 2001 From: Travis Dent Date: Mon, 9 Dec 2024 16:23:21 -0800 Subject: [PATCH] Replace tabs with spaces in crew.py for backwards compatibility with agentstack < 0.2.1 --- agentstack/frameworks/crewai.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/agentstack/frameworks/crewai.py b/agentstack/frameworks/crewai.py index 7c7877f..3fcebef 100644 --- a/agentstack/frameworks/crewai.py +++ b/agentstack/frameworks/crewai.py @@ -19,6 +19,15 @@ class CrewFile(asttools.File): _base_class: Optional[ast.ClassDef] = None + def write(self): + """ + Early versions of the crew entrypoint file used tabs instead of spaces. + This method replaces all tabs with 4 spaces before writing the file to + avoid SyntaxErrors. + """ + self.source = self.source.replace('\t', ' ') + super().write() + def get_base_class(self) -> ast.ClassDef: """A base class is a class decorated with `@CrewBase`.""" if self._base_class is None: # Gets cached to save repeat iteration