Remove questionable dataclass descriptor conformance assertions by BHUVANSH855 · Pull Request #2296 · python/typing
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.xandDC2.yraiseAttributeErrorat runtime because no descriptor instance exists in the class dictionary for those fields.dc2.xanddc2.yevaluate to the storedDesc2instances because non-data descriptors are shadowed by instance attributes.- The
zcase 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