Skip to content

Dataclass descriptors + conformance test problems #2065

Description

@stroxler

Describe the Bug

This issue tracks an interaction between Pyrefly descriptor behavior and the conformance suite.

See this sandbox example, which is adapted from dataclasses_descriptors.py.

The actual behavior doesn't match what the conformance tests expect almost at all: I think that for a dataclass that has a descriptor with no __set__, instances will frequently wind up with raw descriptors as instance attributes although in the presence of optionality I suspect the behavior is unpredictable and you get a union at runtime.

If the descriptor does have a __set__, I'm highly uncertain the runtime behavior; likely the constructor winds up invoking it but I have not yet checked.

In addition, if no value is defined at all and the attribute is annotation only, then it's a pure instance-only attribute and no descriptor behavior exists (this would be true even for a normal class, it's not dataclass-specific) so the conformance tests are 100% wrong here.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions