Skip to content

Commit d25bc6c

Browse files
authored
Removed mandatory enforcement of a dataclass check (#2022)
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.
1 parent 9e4ac47 commit d25bc6c

File tree

9 files changed

+26
-37
lines changed

9 files changed

+26
-37
lines changed
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).
4-
"""
1+
conformant = "Pass"
52
output = """
6-
dataclasses_inheritance.py:60: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc]
7-
dataclasses_inheritance.py:64: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc]
3+
dataclasses_inheritance.py:62: error: Cannot override instance variable (previously declared on base class "DC6") with class variable [misc]
4+
dataclasses_inheritance.py:66: error: Cannot override class variable (previously declared on base class "DC6") with instance variable [misc]
85
"""
9-
conformance_automated = "Fail"
6+
conformance_automated = "Pass"
107
errors_diff = """
11-
Line 47: Expected 1 errors
128
"""

conformance/results/mypy/version.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "mypy 1.16.0"
2-
test_duration = 2.0
2+
test_duration = 1.7
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
conformant = "Partial"
22
notes = """
3-
Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).
43
Does not reject ClassVar that is overridden by instance variable.
54
Does not reject instance variable that is overridden by ClassVar.
65
"""
76
output = """
87
"""
98
conformance_automated = "Fail"
109
errors_diff = """
11-
Line 47: Expected 1 errors
12-
Line 60: Expected 1 errors
13-
Line 64: Expected 1 errors
10+
Line 62: Expected 1 errors
11+
Line 66: Expected 1 errors
1412
"""

conformance/results/pyre/version.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyre 0.9.23"
2-
test_duration = 9.1
2+
test_duration = 6.6

conformance/results/pyright/aliases_typealiastype.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
conformant = "Partial"
2-
notes = """
3-
Incorrectly allows undefined self reference.
4-
"""
1+
conformant = "Pass"
52
output = """
63
aliases_typealiastype.py:32:18 - error: Cannot access attribute "other_attrib" for class "TypeAliasType"
74
  Attribute "other_attrib" is unknown (reportAttributeAccessIssue)
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).
4-
"""
1+
conformant = "Pass"
52
output = """
6-
dataclasses_inheritance.py:60:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride)
7-
dataclasses_inheritance.py:64:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride)
3+
dataclasses_inheritance.py:62:5 - error: Class variable "x" overrides instance variable of same name in class "DC6" (reportIncompatibleVariableOverride)
4+
dataclasses_inheritance.py:66:5 - error: Instance variable "y" overrides class variable of same name in class "DC6" (reportIncompatibleVariableOverride)
85
"""
9-
conformance_automated = "Fail"
6+
conformance_automated = "Pass"
107
errors_diff = """
11-
Line 47: Expected 1 errors
128
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyright 1.1.401"
2-
test_duration = 1.4
2+
test_duration = 1.0

conformance/results/results.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ <h3>Python Type System Conformance Test Results</h3>
159159
<div class="table_container"><table><tbody>
160160
<tr><th class="col1">&nbsp;</th>
161161
<th class='tc-header'><div class='tc-name'>mypy 1.16.0</div>
162-
<div class='tc-time'>2.0sec</div>
162+
<div class='tc-time'>1.7sec</div>
163163
</th>
164164
<th class='tc-header'><div class='tc-name'>pyright 1.1.401</div>
165-
<div class='tc-time'>1.4sec</div>
165+
<div class='tc-time'>1.0sec</div>
166166
</th>
167167
<th class='tc-header'><div class='tc-name'>pyre 0.9.23</div>
168-
<div class='tc-time'>9.1sec</div>
168+
<div class='tc-time'>6.6sec</div>
169169
</th>
170170
</tr>
171171
<tr><th class="column" colspan="4">
@@ -438,7 +438,7 @@ <h3>Python Type System Conformance Test Results</h3>
438438
</tr>
439439
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aliases_typealiastype</th>
440440
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Incorrectly rejects some recursive type aliases using TypeAliasType.</p><p>Incorrectly rejects the use of a class-scoped TypeVar in a TypeAliasType definition.</p></span></div></th>
441-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Incorrectly allows undefined self reference.</p></span></div></th>
441+
<th class="column col2 conformant">Pass</th>
442442
<th class="column col2 not-conformant"><div class="hover-text">Unsupported<span class="tooltip-text" id="bottom"><p>Support for TypeAliasType is not implemented.</p></span></div></th>
443443
</tr>
444444
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aliases_variance</th>
@@ -643,9 +643,9 @@ <h3>Python Type System Conformance Test Results</h3>
643643
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not report when dataclass is not compatible with Hashable protocol.</p></span></div></th>
644644
</tr>
645645
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataclasses_inheritance</th>
646-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).</p></span></div></th>
647-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).</p></span></div></th>
648-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not report when the default value of dataclass field is mutable (is of type list, dict, or set).</p><p>Does not reject ClassVar that is overridden by instance variable.</p><p>Does not reject instance variable that is overridden by ClassVar.</p></span></div></th>
646+
<th class="column col2 conformant">Pass</th>
647+
<th class="column col2 conformant">Pass</th>
648+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not reject ClassVar that is overridden by instance variable.</p><p>Does not reject instance variable that is overridden by ClassVar.</p></span></div></th>
649649
</tr>
650650
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataclasses_kwonly</th>
651651
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Incorrectly rejects kw_only field with default before positional field.</p></span></div></th>

conformance/tests/dataclasses_inheritance.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ class DC4(DC3):
4242

4343
@dataclass
4444
class DC5:
45-
# This should generate an error because a default value of
46-
# type list, dict, or set generate a runtime error.
47-
x: list[int] = [] # E
45+
# While this generates an error at runtime for the stdlib dataclass,
46+
# other libraries that use dataclass_transform don't have similar
47+
# restrictions. It is therefore not required that a type checker
48+
# report an error here.
49+
x: list[int] = [] # E?
4850

4951

5052
@dataclass

0 commit comments

Comments
 (0)