Skip to content

Dataclass descriptors + conformance test problems #2065

Open

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

Activity

  1. self-assigned this
    on Jan 11, 2026
  2. changed the title [-]Dataclass descriptors conformance tests may block correctness[/-] [+]Dataclass descriptors + conformance test problems[/+] on Jan 12, 2026
  3. added theissue type on Jan 12, 2026
  4. stroxler commented on Jan 12, 2026

    @stroxler
    ContributorAuthor

    Self-assigned: I'm working on fixes to Pyrefly that seem to best approximate runtime behavior, I'll reach out to the typing repo once my fixes are in trunk because that will make sharing context easier

    While working on the fix I realized there are more edge cases (data descriptors, self-assignable descriptors) where types potentially work out okay, but the conformance tests are still asserting what seems like wrong behavior to me.

  5. github-actions commented on Jan 29, 2026

    @github-actions

    This issue has someone assigned, but has not had recent activity for more than 2 weeks.

    If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.

    Thank you for your contributions!

  6. added this to the V1 Release milestone on Jan 29, 2026
  7. migeed-z commented on Feb 9, 2026

    @migeed-z
    Contributor

    @stroxler I'm going through some of the conformance related issues and came across this one! is this still something you are working on and would you think it's a good idea to open it up to the community?

  8. stroxler commented on Feb 12, 2026

    @stroxler
    ContributorAuthor

    It's not suitable for a contributor who wants to hack on Pyrefly, it's a typing community problem because I think the existing conformance tests are wrong.

    I'd be fine with someone else taking it on, but most of the people looking at our issues want to hack on Pyrefly, not propose changes that need to go through the typing council

  9. removed their assignment
    on Mar 6, 2026
  10. removed this from the V1 Release milestone on Mar 16, 2026
  11. yangdanny97 commented on Aug 5, 2026

    @yangdanny97
    Collaborator

    relevant issue/PR in the typing repo

    python/typing#2259
    python/typing#2299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions