Skip to content

typing.get_type_hints() works for Callable[[], None] from the typing module, but not collections.abc #91621

@Zac-HD

Description

@Zac-HD

Bug report

typing.get_type_hints() works for Callable[[], None] from the typing module, but not collections.abc. This is the standard way to annotate a callable which takes no arguments, and the generic types from typing should behave identically to those in collections.abc.

import collections.abc import typing def f1(x: typing.Callable[[], None]): pass def f2(x: collections.abc.Callable[[], None]): pass assert "x" in typing.get_type_hints(f1) typing.get_type_hints(f2) # Raises TypeError!

Your environment

CPython 3.11.0a7 (and I believe back to a3), found via CI for Hypothesis, and reproduced in Ubuntu/WSL2 locally.
I'm skipping that test for now, and will re-enable when this is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions