Skip to content

[BUG] Unsupported docstring for class #1189

@ZeusFSX

Description

@ZeusFSX

Describe the bug
Docstring for class and type hitting for variables not working it rise InterpretError

Code to reproduce the error

execution_test_parser = """
class Parser:
    """
    A class to parse e-commerce product pages and extract structured data.
    """
    def __init__(self):
        self.data = {}
        self.soup = None

    def parse(self, html_content: str) -> Dict[str, Any]:
        return {}

# Testing the parser
parser = Parser()
parsed_product = parser.parse(html_text_content)
"""

from smolagents import LocalPythonExecutor

executor = LocalPythonExecutor(additional_authorized_imports=["json", "os", "urllib.parse", "bs4", "pprint", "posixpath", "typing", 'html'])
executor.send_variables({"html_text_content": text_content})  # send the HTML content to the executor
executor.send_tools({})


executor(execution_test_parser)

Error logs (if any)

InterpreterError: Code execution failed at line 'class Parser:
    """
    A class to parse e-commerce product pages and extract structured data.
    """
    def __init__(self):
        self.data = {}
        self.soup = None

    def parse(self, html_content: str) -> Dict[str, Any]:
        return {}' due to: InterpreterError: Unsupported statement in class body: Expr

Packages version:
smolagents==1.12.0

Additional context
also not supported variables type hitting:

def __init__(self):
    self.data: Dict[str, Any] = {}

it will rise InterpreterError: AnnAssign is not supported.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions