Skip to content

self type on property creates a spurious error #3223

Closed
@JelleZijlstra

Description

@JelleZijlstra

Running mypy master on this file:

from typing import TypeVar, List
_T = TypeVar('_T')

class X:
    @property
    def __members__(self: _T) -> List[_T]: ...

reveal_type(X().__members__)

gives

../bin/selftypeproperty.py:8: error: Revealed type is 'builtins.list[selftypeproperty.X*]'
../bin/selftypeproperty.py:8: error: Invalid method type

The revealed type is correct but the "Invalid method type" doesn't make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions