# This sample tests the case where a metaclass defines a descriptor
# protocol (i.e. a `__get__` method), and a member is accessed through
# the class.

from typing import Any, Literal


class _IntDescriptorMeta(type):
    def __get__(self, instance: Any, owner: Any) -> int:
        return 123

    def __set__(self, instance: Any, value: str) -> None:
        pass


class IntDescriptorClass(metaclass=_IntDescriptorMeta):
    ...


class X:
    number_cls = IntDescriptorClass


t1: Literal["int"] = reveal_type(X.number_cls)
t2: Literal["int"] = reveal_type(X().number_cls)

X.number_cls = "hi"
X().number_cls = "hi"

# This should generate an error
X.number_cls = 1

# This should generate an error
X().number_cls = 1

# This sample tests the case where a metaclass defines a descriptor
# protocol (i.e. a `__get__` method), and a member is accessed through
# the class.

from typing import Any, Literal


class _IntDescriptorMeta(type):
    def __get__(self, instance: Any, owner: Any) -> int:
        return 123

    def __set__(self, instance: Any, value: str) -> None:
        pass


class IntDescriptorClass(metaclass=_IntDescriptorMeta):
    ...


class X:
    number_cls = IntDescriptorClass


t1: Literal["int"] = reveal_type(X.number_cls)
t2: Literal["int"] = reveal_type(X().number_cls)

X.number_cls = "hi"
X().number_cls = "hi"

# This should generate an error
X.number_cls = 1

# This should generate an error
X().number_cls = 1

# This sample tests the case where a metaclass defines a descriptor # protocol (i.e. a `__get__` method), and a member is accessed through # the class. # This should generate an error # This should generate an error