Skip to content

variance of generic used in Annotated attribute is affected by usages outside of the class #1846

Description

@DetachHead

Code sample in basedpyright playground

from dataclasses import dataclass
from typing import Annotated


@dataclass
class Foo[T]:
    action: T


def foo[T](value: A[T]):
    asdf = value.value


class A[T]:  # on hover: covariant
    value: Annotated[T, Foo(foo)]


class B[T]:  # on hover: invariant
    value: Annotated[T, Foo(foo)]

this seems to be an existing issue, but something about this behavior has changed in 1.1.411 but i wasnt able to narrow down exactly what

Metadata

Metadata

Assignees

No one assigned

    Labels

    type checking / lintingissues relating to existing diagnostic rules or proposals for new diagnostic rulesupstream buga bug that also exists in pyright but has not been raised upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions