OpenBMB / ProAgent

An LLM-based Agent for the New Automation Paradigm - Agentic Process Automation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError in Python 3.8: 'type' object is not subscriptable in n8nPythonNode Function

zheyuye opened this issue · comments

Description

While working with [Name of the library or project, e.g., n8nPythonNode], I encountered a TypeError when trying to use generic type annotations in Python 3.8. This issue occurs in the function run_node when using the syntax list[dict].

Steps to Reproduce

Use Python 3.8.
Define a function with the following signature:

def run_node(node: n8nPythonNode, input_data: list[dict] = [{}]) -> tuple[str, str]:
    # function body

Run the code.

Expected Behavior
The function should accept a list of dictionaries as an input parameter without any type errors.

Actual Behavior

A TypeError is raised: 'type' object is not subscriptable.

Possible Solution

For Python versions prior to 3.9, it might be necessary to import List and Dict from the typing module for generic type annotations. The function signature can be modified as follows:

from typing import List, Dict, Tuple
def run_node(node: n8nPythonNode, input_data: List[Dict] = [{}]) -> Tuple[str, str]:
# function body

Additional Context

This issue seems to be specific to Python versions below 3.9, where the newer syntax for generic type annotations is not supported.