[ty] Ignore ClassVar declarations when resolving instance members by sharkdp · Pull Request #18241 · astral-sh/ruff (original) (raw)

Make sure that the following definitions all lead to the same outcome (bug originally noticed by @AlexWaygood)

from typing import ClassVar

class Descriptor: def get(self, instance, owner) -> int: return 42

class C: a: ClassVar[Descriptor] b: Descriptor = Descriptor() c: ClassVar[Descriptor] = Descriptor()

reveal_type(C().a) # revealed: int (previously: int | Descriptor) reveal_type(C().b) # revealed: int reveal_type(C().c) # revealed: int