motleycrew.tools.code.python_linter

Functions

create_python_linter_tool()

Classes

PythonLinterInput(*, code[, file_name])

Input for the PythonLinterTool.

PythonLinterTool([return_direct, ...])

Python code verification tool

class motleycrew.tools.code.python_linter.PythonLinterTool(return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None)

Bases: MotleyTool

Python code verification tool

__init__(return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None)

Initialize the MotleyTool.

Parameters:
  • name – Name of the tool (required if tool is None).

  • description – Description of the tool (required if tool is None).

  • args_schema – Schema of the tool arguments (required if tool is None).

  • tool – Langchain BaseTool to wrap.

  • return_direct – If True, the tool’s output will be returned directly to the user.

  • exceptions_to_reflect – List of exceptions to reflect back to the agent.

  • retry_config – Configuration for retry behavior. If None, exceptions will not be retried.

  • is_async – Indicates whether the tool is asynchronous.

class motleycrew.tools.code.python_linter.PythonLinterInput(*, code: str, file_name: str = 'code.py')

Bases: BaseModel

Input for the PythonLinterTool.

code: str
file_name: str
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'code': FieldInfo(annotation=str, required=True, description='Python code for linting'), 'file_name': FieldInfo(annotation=str, required=False, default='code.py', description='file name for the code')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

motleycrew.tools.code.python_linter.create_python_linter_tool() StructuredTool