Dataclass descriptors + conformance test problems
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
This issue tracks an interaction between Pyrefly descriptor behavior and the conformance suite.
See [this sandbox example](https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxAAQDqMUAxrgLYzUAuunAFuwAqkATjDBRS1AMoYcBADS8IcakuqpqxVAHMYAHXQ0A7nxHVSuAK7VGGaoaEQOMBXB6pTM6rHfo1eCxycpMQQ6FoqvoIcPLjohPqUCdQAEjAeHtaWxLDUYDCoHBYiyrhgispoWHj4iEkAtNQA4jCBIqhQdRwQbEHE7Ix8jADWoeF5MDiow-XUAKpw7CIAbvlQAPocwTAAFACUnNyhcH2MgaF5QiKYvfAzMPh9DmzogYaOPLzsAJIAIgCiuXyhWKvAKdnYcAsxGIuCEgW2MEIWkIagCuGYLGyLWc1C0uE6%2BMwolCjggsQUMRWQgULUYuxmtAcTjUWGoQgskVI0VimSJ1EwEBEp3EETMliE1GwQlwhgWQn0YGlLF6oxUmNhgVwVKguFQmAUAEF0KQFKg4HKOBstgqlfyClMoGaFspujC4XaOA6nfp9IxHebqD94IwAEy1XzUSMAAS1aR1ev0kcjRLKazWOkta22CygYAUR096EYMEQ1AAcrEcTL0GlS0bSPs6gA%2BahwDhCcNJrvUQi9n0R6OxoTxzCJpMp6hpjNp7MMPMRNsYYul3DYABWMFOCmrteo9cbLdCHE73cjvfi6DHydEk-TLRnOfnBaXJeoq43p2oAB9y5Xt4Yaw7PdjQPVt22-CJjyvbsIDKZ8i3YVQKxrUsRGBXxdBAABWTDoK7BgFlQloil8HDL3IqNMHtP1vSLf1lB%2BABhMNoJqQNgxDaDSFLIM4FDaCAC9qAAXnYviQz2fsEidNJLU2PptiYkNCHwFx23pAwZLhK0FKUwgTTAoQNK0uStkU5jCAEtSjP7TBQxEwNmMUji9gUXjQz2DTiAcF5thMnSdjs5TVMg3YvJ8jg-PNWSAu2IL9PzF4wv0byjyii1YviqzQt2EA5BAAJoDgEhyEQKg5i6KBHAkMAOVOMl0DgWybzAWEWAKNZ0AsFhsDSbY2KPUC2w7aC0JI3JMLLbreqA4B8AAX1w9A8pAMgRDEUhCC4FgoAoGhBHWkVKlkfBMnQSAtCKAoGovGhJBgdgeA4DhiDgRAAHp3rW0RxEIWEtHemB0HezB0Tgd7mHOiBLqEa7Yne3JYTUJZUGgVBsBySGLquroeVwYhccai8yG5dA6ipOAGoczCAGZCAARk4kB9BAeb8qmLoVgAMWgGAKGO6oStZoA), 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_
Contributor guide
Assessment
This issue has not been assessed yet.