Skip to content

Enum and typing.Self seems incompatible types. #7712

@AlexanderPodorov

Description

@AlexanderPodorov

Describe the bug
See example code, the last line shows a warning, however it should not.

Code or Screenshots

from collections.abc import Sequence
from enum import StrEnum
from typing import Self


class Test(StrEnum):
    A = "a"
    B = "b"

    @classmethod
    def test(cls) -> Sequence[Self]:
        return [cls.A, cls.B]  # shows warning, seems it should not

VS Code extension or command-line
Pylance v2024.4.101 (pre-release), pyright 1.1.358.

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intendedbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions