Skip to content
The Chat Archive
Mistralmistral-medium-2505· Mistral AI LMArena Human Preference 140K

I have a Python function (3.13): [code] Pylance is complaining: Call expression not…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4.1-mini-2025-04-14’s answer.
  1. User

    I have a Python function (3.13):

    def get_cands(term: str) -> list[tuple(str, str)]:
    

    Pylance is complaining: Call expression not allowed in type expression and Expected 1 positional argument

  2. Assistant

    The error messages you're seeing are related to how you're specifying the return type annotation in your Python function. In Python 3.13, the correct way to annotate a list of tuples containing strings would be:

    def get_cands(term: str) -> list[tuple[str, str]]:
    

    The issues in your original code are:

    1. You're using str instead of str in the tuple annotation (though this might have been a typo in your question)
    2. The main problem is that you're using parentheses () in the type annotation, which is incorrect syntax for type hints. You should use square brackets [] for the list type and square brackets for the tuple type as well.

    The correct syntax is:

    • list[...] for lists
    • tuple[...] for tuples
    • str for strings (no parentheses)

    If you're using Python 3.9+, you can also use the more modern syntax with list and tuple directly (without importing from typing):

    def get_cands(term: str) -> list[tuple[str, str]]:
        # function implementation
        return []
    

    If you need to support older Python versions (pre-3.9), you would need to import these from typing:

    from typing import List, Tuple
    
    def get_cands(term: str) -> List[Tuple[str, str]]:
        # function implementation
        return []
    

    But since you mentioned Python 3.13, the first version is perfectly valid.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.