Skip to content

Instance attribute should take precedence over non-data descriptors in attribute writes #253

Open
@grievejia

Description

@grievejia

Describe the Bug

Minimal repro:

class NonDataDescriptor:
    def __get__(self, instance: object, owner: type | None = None) -> str:
        return "derp"

class C:
    x = NonDataDescriptor()

    def f(self):
        self.x = 1  # This is okay

Expected: No error
Actual: Attribute x of class C is a read-only descriptor with no __set__ and cannot be set

Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAEByD2A7AImALmZBTCwBOAlgA5rx4BcAUNDdACZYBm0A+iwOZZpsAUEWIRgBpoBRBAyJgWctHgAjAFZZgaEfADuiLBWhoAnkSzQAPnCTGAvOe0BKaAFoAfNAkVqtT3i4BXPImgAIgY8IkDKSlBIGABhKk8AD2hrBBR0TBx8YlI8HlsIzwZmRj4BRlt4z1p+QQA6JOsARhoAYmgAFQALAhgeuQBrMH0gA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions