Skip to content

In some cases, a useless temporary variable needs to be used with Annotated #7049

@guillaume-alliander

Description

@guillaume-alliander

Describe the bug
I am not too sure what is actually going on. I think that the code is the best way to describe the issue. The workaround works, so it is fine for now, but I do think there's a bug.

Code

from typing import Annotated, Type

def weird[T](p: tuple[Type[T], T]) -> Type[T]:
    return Annotated[p[0], p[1]] # error:  Expected type expression but received "tuple[type[T@weird], T@weird]"
    
    # Alternatives:
    t = p[0]
    return Annotated[t, p[1]] # workaround, no error
    
    return p[0] # not what I want, but no error

VS Code extension or command-line
On the command line, but pylance has the same issue.

pyright --version
pyright 1.1.347

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions