Skip to content

TypeError: '|' not supported between instances of '_CallableGenericAlias' and 'NoneType' #5711

Open
@starpit

Description

@starpit

Feature

The following fails on rustpython but succeeds on cpython3.12

from collections.abc import Awaitable, Callable
from typing import TypeVar

T = TypeVar("T")

async def abort_signal_handler(
    fn: Callable[[], Awaitable[T]], on_abort: Callable[[], None] | None = None
) -> T:
    pass

Traceback (most recent call last):
File "/tmp/foo.py", line 7, in
fn: Callable[[], Awaitable[T]], on_abort: Callable[[], None] | None = None
TypeError: '|' not supported between instances of '_CallableGenericAlias' and 'NoneType'

Python Documentation or reference to CPython source code

I'm not sure. I have tried comparing RustPython's typing.py to cpython's. There are differences in the treatment of Callable.

https://github.com/python/cpython/blob/main/Lib/typing.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions