Skip to content

Remove questionable dataclass descriptor conformance assertions#2296

Open
BHUVANSH855 wants to merge 2 commits into
python:mainfrom
BHUVANSH855:fix-2259-dataclass-descriptor-tests
Open

Remove questionable dataclass descriptor conformance assertions#2296
BHUVANSH855 wants to merge 2 commits into
python:mainfrom
BHUVANSH855:fix-2259-dataclass-descriptor-tests

Conversation

@BHUVANSH855
Copy link
Copy Markdown
Contributor

Summary

Remove questionable Desc2 conformance assertions from dataclasses_descriptors.py.

The existing assertions do not align with actual runtime behavior for non-data descriptors in dataclasses:

  • DC2.x and DC2.y raise AttributeError at runtime because no descriptor instance exists in the class dictionary for those fields.
  • dc2.x and dc2.y evaluate to the stored Desc2 instances because non-data descriptors are shadowed by instance attributes.
  • The z case is also subtle due to descriptor access during dataclass default extraction.

Since this behavior is currently under-specified and differs across type checkers and runtime semantics, this PR removes the questionable assertions and replaces them with explanatory comments.

Fixes #2259

@BHUVANSH855 BHUVANSH855 force-pushed the fix-2259-dataclass-descriptor-tests branch from aee0e78 to 15e4fe0 Compare May 28, 2026 17:26
@BHUVANSH855 BHUVANSH855 force-pushed the fix-2259-dataclass-descriptor-tests branch from 15e4fe0 to c48ab35 Compare May 28, 2026 17:29
@BHUVANSH855 BHUVANSH855 force-pushed the fix-2259-dataclass-descriptor-tests branch from 09c8961 to d6caba9 Compare May 28, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conformance suite: Questionable tests in dataclasses_descriptors.py

1 participant