From 6893861c149ef77258e3751f96e372029a99a7b8 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 10 Jun 2025 07:04:53 -0700 Subject: [PATCH] Removed mandatory enforcement of "default value type of list, dict, or set" for dataclass fields in the `dataclasses_inheritance` test. This error is now optional for type checkers. Also fixed the conformance summary for pyright in the `aliases_typealiastype` test, which was out of date and didn't reflect the fact that pyright now passes this test. --- .../results/mypy/dataclasses_inheritance.toml | 12 ++++-------- conformance/results/mypy/version.toml | 2 +- .../results/pyre/dataclasses_inheritance.toml | 6 ++---- conformance/results/pyre/version.toml | 2 +- .../results/pyright/aliases_typealiastype.toml | 5 +---- .../results/pyright/dataclasses_inheritance.toml | 12 ++++-------- conformance/results/pyright/version.toml | 2 +- conformance/results/results.html | 14 +++++++------- conformance/tests/dataclasses_inheritance.py | 8 +++++--- 9 files changed, 26 insertions(+), 37 deletions(-) diff --git a/conformance/results/mypy/dataclasses_inheritance.toml b/conformance/results/mypy/dataclasses_inheritance.toml index 1345599e0..c90115220 100644 --- a/conformance/results/mypy/dataclasses_inheritance.toml +++ b/conformance/results/mypy/dataclasses_inheritance.toml @@ -1,12 +1,8 @@ -conformant = "Partial" -notes = """ -Does not report when the default value of dataclass field is mutable (is of type list, dict, or set). -""" +conformant = "Pass" output = """ -dataclasses_inheritance.py:60: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] -dataclasses_inheritance.py:64: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] +dataclasses_inheritance.py:62: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc] +dataclasses_inheritance.py:66: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc] """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 47: Expected 1 errors """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index a62332be1..eb3ca14aa 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1,2 @@ version = "mypy 1.16.0" -test_duration = 2.0 +test_duration = 1.7 diff --git a/conformance/results/pyre/dataclasses_inheritance.toml b/conformance/results/pyre/dataclasses_inheritance.toml index 4ace5b68c..1afca3581 100644 --- a/conformance/results/pyre/dataclasses_inheritance.toml +++ b/conformance/results/pyre/dataclasses_inheritance.toml @@ -1,6 +1,5 @@ conformant = "Partial" notes = """ -Does not report when the default value of dataclass field is mutable (is of type list, dict, or set). Does not reject ClassVar that is overridden by instance variable. Does not reject instance variable that is overridden by ClassVar. """ @@ -8,7 +7,6 @@ output = """ """ conformance_automated = "Fail" errors_diff = """ -Line 47: Expected 1 errors -Line 60: Expected 1 errors -Line 64: Expected 1 errors +Line 62: Expected 1 errors +Line 66: Expected 1 errors """ diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index 5b949f6ad..cda658b76 100644 --- a/conformance/results/pyre/version.toml +++ b/conformance/results/pyre/version.toml @@ -1,2 +1,2 @@ version = "pyre 0.9.23" -test_duration = 9.1 +test_duration = 6.6 diff --git a/conformance/results/pyright/aliases_typealiastype.toml b/conformance/results/pyright/aliases_typealiastype.toml index e0f4a8c93..8bd8d47da 100644 --- a/conformance/results/pyright/aliases_typealiastype.toml +++ b/conformance/results/pyright/aliases_typealiastype.toml @@ -1,7 +1,4 @@ -conformant = "Partial" -notes = """ -Incorrectly allows undefined self reference. -""" +conformant = "Pass" output = """ aliases_typealiastype.py:32:18 - error: Cannot access attribute "other_attrib" for class "TypeAliasType"   Attribute "other_attrib" is unknown (reportAttributeAccessIssue) diff --git a/conformance/results/pyright/dataclasses_inheritance.toml b/conformance/results/pyright/dataclasses_inheritance.toml index 935f8e918..8576bb702 100644 --- a/conformance/results/pyright/dataclasses_inheritance.toml +++ b/conformance/results/pyright/dataclasses_inheritance.toml @@ -1,12 +1,8 @@ -conformant = "Partial" -notes = """ -Does not report when the default value of dataclass field is mutable (is of type list, dict, or set). -""" +conformant = "Pass" output = """ -dataclasses_inheritance.py:60:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride) -dataclasses_inheritance.py:64:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride) +dataclasses_inheritance.py:62:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride) +dataclasses_inheritance.py:66:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride) """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 47: Expected 1 errors """ diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index 32f55ae40..e3b370522 100644 --- a/conformance/results/pyright/version.toml +++ b/conformance/results/pyright/version.toml @@ -1,2 +1,2 @@ version = "pyright 1.1.401" -test_duration = 1.4 +test_duration = 1.0 diff --git a/conformance/results/results.html b/conformance/results/results.html index b50f2db9d..1903a7bfd 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -159,13 +159,13 @@

Python Type System Conformance Test Results

- + @@ -643,9 +643,9 @@

Python Type System Conformance Test Results

- - - + + + diff --git a/conformance/tests/dataclasses_inheritance.py b/conformance/tests/dataclasses_inheritance.py index fe6263e68..3ed0b88db 100644 --- a/conformance/tests/dataclasses_inheritance.py +++ b/conformance/tests/dataclasses_inheritance.py @@ -42,9 +42,11 @@ class DC4(DC3): @dataclass class DC5: - # This should generate an error because a default value of - # type list, dict, or set generate a runtime error. - x: list[int] = [] # E + # While this generates an error at runtime for the stdlib dataclass, + # other libraries that use dataclass_transform don't have similar + # restrictions. It is therefore not required that a type checker + # report an error here. + x: list[int] = [] # E? @dataclass
 
mypy 1.16.0
-
2.0sec
+
1.7sec
pyright 1.1.401
-
1.4sec
+
1.0sec
pyre 0.9.23
-
9.1sec
+
6.6sec
@@ -438,7 +438,7 @@

Python Type System Conformance Test Results

     aliases_typealiastype
Partial

Incorrectly rejects some recursive type aliases using TypeAliasType.

Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition.

Partial

Incorrectly allows undefined self reference.

Pass
Unsupported

Support for TypeAliasType is not implemented.

     aliases_variance
Partial

Does not report when dataclass is not compatible with Hashable protocol.

     dataclasses_inheritance
Partial

Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).

Partial

Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).

Partial

Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).

Does not reject ClassVar that is overridden by instance variable.

Does not reject instance variable that is overridden by ClassVar.

PassPass
Partial

Does not reject ClassVar that is overridden by instance variable.

Does not reject instance variable that is overridden by ClassVar.

     dataclasses_kwonly
Partial

Incorrectly rejects kw_only field with default before positional field.