Skip to content

get_type_hints doesn't work properly with lambdasΒ #133230

@DetachHead

Description

@DetachHead

Bug report

Bug description:

from __future__ import annotations

from typing import Annotated, cast, get_type_hints


class Foo:
    a: Annotated[int, lambda: cast]


get_type_hints(Foo, include_extras=True)["a"].__metadata__[0]() # NameError: name 'cast' is not defined

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions