From 0534ecb1636d05d8de1ed43ab3293e11c62c7b6c Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 13 Nov 2026 02:35:35 -0800 Subject: [PATCH 1/2] conformance: allow error on line 58 of dataclasses_descriptors.py --- .../results/pyrefly/dataclasses_descriptors.toml | 8 +------- conformance/results/results.html | 12 +++--------- conformance/tests/dataclasses_descriptors.py | 2 +- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/conformance/results/pyrefly/dataclasses_descriptors.toml b/conformance/results/pyrefly/dataclasses_descriptors.toml index 21e34e3c3..458790e96 100644 --- a/conformance/results/pyrefly/dataclasses_descriptors.toml +++ b/conformance/results/pyrefly/dataclasses_descriptors.toml @@ -1,11 +1,5 @@ -conformant = "Partial" -notes = """ -Assumes descriptor behavior only when field is assigned in class body -Doesn't allow non-data descriptors or data descriptors with differing `__get__` and `__set__` types -""" -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 58: Unexpected errors ['Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor]'] """ output = """ ERROR dataclasses_descriptors.py:58:5-6: Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor] diff --git a/conformance/results/results.html b/conformance/results/results.html index 94a105325..ae1e9b0d9 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -1743,13 +1743,7 @@

Python Type System Conformance Test Results

  • Conformance suite is questionable; see https://github.com/python/typing/issues/2259
  • - - Partial - - + Pass Pass Partial @@ -1937,7 +1931,7 @@

    Python Type System Conformance Test Results

    11.5 / 16 • 71.9% 15.5 / 16 • 96.9% - 15.5 / 16 • 96.9% + 16 / 16 • 100.0% 16 / 16 • 100.0% 15.5 / 16 • 96.9% 16 / 16 • 100.0% @@ -2534,7 +2528,7 @@

    Python Type System Conformance Test Results

    110 / 146 • 75.3% 138.5 / 146 • 94.9% - 142 / 146 • 97.3% + 142.5 / 146 • 97.6% 140.5 / 146 • 96.2% 141 / 146 • 96.6% 146 / 146 • 100.0% diff --git a/conformance/tests/dataclasses_descriptors.py b/conformance/tests/dataclasses_descriptors.py index f2f30a623..61b7ff635 100644 --- a/conformance/tests/dataclasses_descriptors.py +++ b/conformance/tests/dataclasses_descriptors.py @@ -55,7 +55,7 @@ def __get__(self, instance: object | None, owner: Any) -> list[T] | T: class DC2: x: Desc2[int] y: Desc2[str] - z: Desc2[str] = Desc2() + z: Desc2[str] = Desc2() # E?: a non-data descriptor default may be rejected assert_type(DC2.x, list[int]) From 6fe6a161310339fe9349f90ad5ce58cb68388776 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 13 Nov 2026 10:58:01 -0800 Subject: [PATCH 2/2] Delete questionable portions of dataclasses_descriptors test instead. --- .../results/mypy/dataclasses_descriptors.toml | 15 +------- .../pycroscope/dataclasses_descriptors.toml | 20 +---------- .../pyrefly/dataclasses_descriptors.toml | 1 - conformance/results/results.html | 34 +++++-------------- .../results/ty/dataclasses_descriptors.toml | 10 +----- conformance/tests/dataclasses_descriptors.py | 30 ---------------- 6 files changed, 12 insertions(+), 98 deletions(-) diff --git a/conformance/results/mypy/dataclasses_descriptors.toml b/conformance/results/mypy/dataclasses_descriptors.toml index e47310293..fb8cbefae 100644 --- a/conformance/results/mypy/dataclasses_descriptors.toml +++ b/conformance/results/mypy/dataclasses_descriptors.toml @@ -1,18 +1,5 @@ -conformant = "Partial" -notes = """ -Assumes descriptor behavior only when field is assigned in class body. -Does not correctly evaluate type of descriptor access. -""" output = """ -dataclasses_descriptors.py:61: error: Cannot access instance-only attribute "x" on class object [misc] -dataclasses_descriptors.py:62: error: Cannot access instance-only attribute "y" on class object [misc] -dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type] -dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 61: Unexpected errors ['dataclasses_descriptors.py:61: error: Cannot access instance-only attribute "x" on class object [misc]'] -Line 62: Unexpected errors ['dataclasses_descriptors.py:62: error: Cannot access instance-only attribute "y" on class object [misc]'] -Line 66: Unexpected errors ['dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type]'] -Line 67: Unexpected errors ['dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type]'] """ diff --git a/conformance/results/pycroscope/dataclasses_descriptors.toml b/conformance/results/pycroscope/dataclasses_descriptors.toml index 5b89c7ef9..cdd4d0cd9 100644 --- a/conformance/results/pycroscope/dataclasses_descriptors.toml +++ b/conformance/results/pycroscope/dataclasses_descriptors.toml @@ -1,23 +1,5 @@ -conformant = "Partial" -notes = """ -Conformance suite is questionable; see -""" -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 61: Unexpected errors ['./dataclasses_descriptors.py:61:12: Any[error] is not equivalent to list[int]', "./dataclasses_descriptors.py:61:12: has no attribute 'x' [undefined_attribute]"] -Line 62: Unexpected errors ['./dataclasses_descriptors.py:62:12: Any[error] is not equivalent to list[str]', "./dataclasses_descriptors.py:62:12: has no attribute 'y' [undefined_attribute]"] -Line 63: Unexpected errors ['./dataclasses_descriptors.py:63:12: list[Any[generic_argument]] is not equivalent to list[str]'] -Line 66: Unexpected errors ['./dataclasses_descriptors.py:66:12: ./dataclasses_descriptors.py.Desc2[int] is not equivalent to int'] -Line 67: Unexpected errors ['./dataclasses_descriptors.py:67:12: ./dataclasses_descriptors.py.Desc2[str] is not equivalent to str'] -Line 68: Unexpected errors ['./dataclasses_descriptors.py:68:12: Any[generic_argument] is not equivalent to str'] """ output = """ -./dataclasses_descriptors.py:61:12: Any[error] is not equivalent to list[int] -./dataclasses_descriptors.py:61:12: has no attribute 'x' [undefined_attribute] -./dataclasses_descriptors.py:62:12: Any[error] is not equivalent to list[str] -./dataclasses_descriptors.py:62:12: has no attribute 'y' [undefined_attribute] -./dataclasses_descriptors.py:63:12: list[Any[generic_argument]] is not equivalent to list[str] -./dataclasses_descriptors.py:66:12: ./dataclasses_descriptors.py.Desc2[int] is not equivalent to int -./dataclasses_descriptors.py:67:12: ./dataclasses_descriptors.py.Desc2[str] is not equivalent to str -./dataclasses_descriptors.py:68:12: Any[generic_argument] is not equivalent to str """ diff --git a/conformance/results/pyrefly/dataclasses_descriptors.toml b/conformance/results/pyrefly/dataclasses_descriptors.toml index 458790e96..cdd4d0cd9 100644 --- a/conformance/results/pyrefly/dataclasses_descriptors.toml +++ b/conformance/results/pyrefly/dataclasses_descriptors.toml @@ -2,5 +2,4 @@ conformance_automated = "Pass" errors_diff = """ """ output = """ -ERROR dataclasses_descriptors.py:58:5-6: Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor] """ diff --git a/conformance/results/results.html b/conformance/results/results.html index ae1e9b0d9..2525a3b81 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -1730,27 +1730,11 @@

    Python Type System Conformance Test Results

    dataclasses_descriptors - - Partial -
      -
    • Assumes descriptor behavior only when field is assigned in class body.
    • -
    • Does not correctly evaluate type of descriptor access.
    • -
    - - - Partial - - Pass Pass - - Partial -
      -
    • Only infers a descriptor __get__ method as being called when a descriptor attribute is accessed on an instance if the descriptor attribute is present in the class namespace.
    • -
    - + Pass + Pass + Pass Pass @@ -1929,11 +1913,11 @@

    Python Type System Conformance Test Results

    - 11.5 / 16 • 71.9% - 15.5 / 16 • 96.9% + 12 / 16 • 75.0% + 16 / 16 • 100.0% + 16 / 16 • 100.0% 16 / 16 • 100.0% 16 / 16 • 100.0% - 15.5 / 16 • 96.9% 16 / 16 • 100.0% @@ -2526,11 +2510,11 @@

    Python Type System Conformance Test Results

    - 110 / 146 • 75.3% - 138.5 / 146 • 94.9% + 110.5 / 146 • 75.7% + 139 / 146 • 95.2% 142.5 / 146 • 97.6% 140.5 / 146 • 96.2% - 141 / 146 • 96.6% + 141.5 / 146 • 96.9% 146 / 146 • 100.0% diff --git a/conformance/results/ty/dataclasses_descriptors.toml b/conformance/results/ty/dataclasses_descriptors.toml index 91ad20b90..cdd4d0cd9 100644 --- a/conformance/results/ty/dataclasses_descriptors.toml +++ b/conformance/results/ty/dataclasses_descriptors.toml @@ -1,13 +1,5 @@ -conformance_automated = "Fail" -conformant = "Partial" -notes = """ -Only infers a descriptor `__get__` method as being called when a descriptor attribute is accessed on an instance if the descriptor attribute is present in the class namespace. -""" +conformance_automated = "Pass" errors_diff = """ -Line 66: Unexpected errors ['dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int | Desc2[int]` does not match asserted type `int`'] -Line 67: Unexpected errors ['dataclasses_descriptors.py:67:1: error[type-assertion-failure] Type `str | Desc2[str]` does not match asserted type `str`'] """ output = """ -dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int | Desc2[int]` does not match asserted type `int` -dataclasses_descriptors.py:67:1: error[type-assertion-failure] Type `str | Desc2[str]` does not match asserted type `str` """ diff --git a/conformance/tests/dataclasses_descriptors.py b/conformance/tests/dataclasses_descriptors.py index 61b7ff635..beea1a0b7 100644 --- a/conformance/tests/dataclasses_descriptors.py +++ b/conformance/tests/dataclasses_descriptors.py @@ -36,33 +36,3 @@ class DC1: assert_type(dc1.y, int) assert_type(DC1.y, Desc1) - - -class Desc2(Generic[T]): - @overload - def __get__(self, instance: None, owner: Any) -> list[T]: - ... - - @overload - def __get__(self, instance: object, owner: Any) -> T: - ... - - def __get__(self, instance: object | None, owner: Any) -> list[T] | T: - raise NotImplementedError - - -@dataclass -class DC2: - x: Desc2[int] - y: Desc2[str] - z: Desc2[str] = Desc2() # E?: a non-data descriptor default may be rejected - - -assert_type(DC2.x, list[int]) -assert_type(DC2.y, list[str]) -assert_type(DC2.z, list[str]) - -dc2 = DC2(Desc2(), Desc2(), Desc2()) -assert_type(dc2.x, int) -assert_type(dc2.y, str) -assert_type(dc2.z, str)