Skip to content

Conformance: remove non-data-descriptor tests in dataclasses_descriptors.py#2319

Closed
ashishpatel26 wants to merge 1 commit into
python:mainfrom
ashishpatel26:fix/issue-2259-remove-bogus-descriptor-tests
Closed

Conformance: remove non-data-descriptor tests in dataclasses_descriptors.py#2319
ashishpatel26 wants to merge 1 commit into
python:mainfrom
ashishpatel26:fix/issue-2259-remove-bogus-descriptor-tests

Conversation

@ashishpatel26

Copy link
Copy Markdown
Contributor

Summary

  • The Desc2/DC2 test in dataclasses_descriptors.py asserted type-checker behavior for non-data descriptors (objects with __get__ but no __set__) used as dataclass fields.
  • Those assertions don't match runtime behavior: fields typed with a non-data descriptor are stored as plain instance attributes on init, so the descriptor's __get__ never actually fires on instance access.
  • Per the issue, pyrefly gets this right (and thus fails the test), while mypy/pyright pass the test but implement the wrong behavior.
  • Removed the incorrect assertions; kept the Desc1 (data descriptor) case, which is correctly specified and confirmed against runtime.
  • Regenerated conformance results for dataclasses_descriptors.toml across all checkers and results.html; reconciled conformant flags that referenced the now-removed behavior.

Fixes #2259

Test plan

  • uv run python src/main.py — reran full conformance suite, confirmed only dataclasses_descriptors results changed for the intended checkers
  • uv run python src/validate_results.py — 987 files validated, 0 invariant violations
  • Diff scoped to conformance/tests/dataclasses_descriptors.py, the 4 affected results/*/dataclasses_descriptors.toml, and results.html

…ors.py

The Desc2/DC2 test case asserted that dataclass fields typed with a
non-data descriptor (a class implementing only __get__, no __set__)
resolve through the descriptor protocol. That assertion doesn't match
runtime behavior: such fields are stored as plain instance attributes,
so the descriptor's __get__ never runs on instance access.

The correct behavior for non-data descriptors in dataclasses is
underspecified, so remove the incorrect assertions until the spec
covers this case. The Desc1 (data descriptor) test, which is correct
and confirmed against runtime, is unaffected.

Fixes python#2259
@davidhalter

Copy link
Copy Markdown
Collaborator

I'm closing this, since you already opened a pull request for the same issue: #2299.

Please next time check at least the issue you're trying to fix for your own pull requests and other pull requests. Also please check for others who have tried to solve the issue. This is just wasting maintainer time.

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

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conformance suite: Questionable tests in dataclasses_descriptors.py

3 participants