diff --git a/conformance/results/mypy/dataclasses_descriptors.toml b/conformance/results/mypy/dataclasses_descriptors.toml index e4731029..e9e4aa78 100644 --- a/conformance/results/mypy/dataclasses_descriptors.toml +++ b/conformance/results/mypy/dataclasses_descriptors.toml @@ -1,18 +1,7 @@ -conformant = "Partial" +conformant = "Pass" 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" -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]'] +Previously failed due to assumptions about non-data descriptor behavior in +dataclasses that were removed from the conformance test because the behavior +is currently under-specified. """ +conformance_automated = "Pass" diff --git a/conformance/results/pycroscope/dataclasses_descriptors.toml b/conformance/results/pycroscope/dataclasses_descriptors.toml index e5410991..e9e4aa78 100644 --- a/conformance/results/pycroscope/dataclasses_descriptors.toml +++ b/conformance/results/pycroscope/dataclasses_descriptors.toml @@ -1,23 +1,7 @@ -conformant = "Partial" +conformant = "Pass" notes = """ -Conformance suite is questionable; see https://github.com/python/typing/issues/2259 -""" -conformance_automated = "Fail" -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 +Previously failed due to assumptions about non-data descriptor behavior in +dataclasses that were removed from the conformance test because the behavior +is currently under-specified. """ +conformance_automated = "Pass" diff --git a/conformance/results/pyrefly/dataclasses_descriptors.toml b/conformance/results/pyrefly/dataclasses_descriptors.toml index e2ae83bf..cf302d41 100644 --- a/conformance/results/pyrefly/dataclasses_descriptors.toml +++ b/conformance/results/pyrefly/dataclasses_descriptors.toml @@ -2,21 +2,14 @@ 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 +* Assertions related to under-specified non-data descriptor behavior were removed from the conformance test """ conformance_automated = "Fail" errors_diff = """ Line 32: Unexpected errors ['Cannot set field `y` to data descriptor `Desc1` with inconsistent types [bad-class-definition]'] Line 58: Unexpected errors ['Cannot set field `z` to non-data descriptor `Desc2` [bad-class-definition]'] -Line 61: Unexpected errors ['assert_type(Desc2[int], list[int]) failed [assert-type]'] -Line 62: Unexpected errors ['assert_type(Desc2[str], list[str]) failed [assert-type]'] -Line 66: Unexpected errors ['assert_type(Desc2[int], int) failed [assert-type]'] -Line 67: Unexpected errors ['assert_type(Desc2[str], str) failed [assert-type]'] """ output = """ ERROR dataclasses_descriptors.py:32:5-6: Cannot set field `y` to data descriptor `Desc1` with inconsistent types [bad-class-definition] ERROR dataclasses_descriptors.py:58:5-6: Cannot set field `z` to non-data descriptor `Desc2` [bad-class-definition] -ERROR dataclasses_descriptors.py:61:12-30: assert_type(Desc2[int], list[int]) failed [assert-type] -ERROR dataclasses_descriptors.py:62:12-30: assert_type(Desc2[str], list[str]) failed [assert-type] -ERROR dataclasses_descriptors.py:66:12-24: assert_type(Desc2[int], int) failed [assert-type] -ERROR dataclasses_descriptors.py:67:12-24: assert_type(Desc2[str], str) failed [assert-type] """ diff --git a/conformance/results/results.html b/conformance/results/results.html index 0edd52cc..bade5ee0 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -900,12 +900,12 @@

Python Type System Conformance Test Results

Dataclasses      dataclasses_descriptors -
Partial

Assumes descriptor behavior only when field is assigned in class body.

Does not correctly evaluate type of descriptor access.

+
Pass*

Previously failed due to assumptions about non-data descriptor behavior in

dataclasses that were removed from the conformance test because the behavior

is currently under-specified.

Pass Pass -
Partial

* 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

-
Partial

Conformance suite is questionable; see https://github.com/python/typing/issues/2259

-
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.

+
Partial

* 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

* Assertions related to under-specified non-data descriptor behavior were removed from the conformance test

+
Pass*

Previously failed due to assumptions about non-data descriptor behavior in

dataclasses that were removed from the conformance test because the behavior

is currently under-specified.

+
Pass*

Previously failed due to assumptions about non-data descriptor behavior in

dataclasses that were removed from the conformance test because the behavior

is currently under-specified.

     dataclasses_final
Partial

Wrongly requires a Final dataclass field to be initialized at class level.

Doesn't support Final nested inside ClassVar.

diff --git a/conformance/results/ty/dataclasses_descriptors.toml b/conformance/results/ty/dataclasses_descriptors.toml index 91ad20b9..3f2f0636 100644 --- a/conformance/results/ty/dataclasses_descriptors.toml +++ b/conformance/results/ty/dataclasses_descriptors.toml @@ -1,13 +1,7 @@ -conformance_automated = "Fail" -conformant = "Partial" +conformance_automated = "Pass" +conformant = "Pass" 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. -""" -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` +Previously failed due to assumptions about non-data descriptor behavior in +dataclasses that were removed from the conformance test because the behavior +is currently under-specified. """ diff --git a/conformance/tests/dataclasses_descriptors.py b/conformance/tests/dataclasses_descriptors.py index f2f30a62..63c817fc 100644 --- a/conformance/tests/dataclasses_descriptors.py +++ b/conformance/tests/dataclasses_descriptors.py @@ -58,11 +58,17 @@ class DC2: z: Desc2[str] = Desc2() -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) +# Runtime behavior involving non-data descriptors in dataclasses is +# currently under-specified and differs across type checkers and runtime +# implementations. +# +# In particular: +# - DC2.x and DC2.y raise AttributeError at runtime because no descriptor +# instance is stored 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 behavior for z is also subtle because dataclasses access the +# descriptor during default extraction. +# +# These cases are therefore omitted from the conformance suite until the +# expected behavior is specified more clearly.