KEMBAR78
Failed to resolve the boundary type in a PEP 695 new style definition · Issue #17347 · python/mypy · GitHub
Skip to content

Failed to resolve the boundary type in a PEP 695 new style definition #17347

@danpascu

Description

@danpascu

The following code:

class ComparableNumber[T: ComparableNumber](Protocol):
    def __lt__(self, other: T, /) -> bool: ...
    def __gt__(self, other: T, /) -> bool: ...
    def __int__(self) -> int: ...

Fails with:

_typing.py:15: error: Cannot resolve name "ComparableNumber" (possible cyclic definition)  [misc]

Pyright seems to accept it with no issue and python itself doesn't complain or raise any exception when this definition is loaded at runtime.

This is with the current head version from github with default configuration, no command line switches and with

# mypy: enable-incomplete-feature=NewGenericSyntax

being used in the file where this is defined.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions