Skip to content

Commit 6d2f52c

Browse files
authored
conformance: delete questionable portions of dataclasses_descriptors test (#2388)
* conformance: allow error on line 58 of dataclasses_descriptors.py * Delete questionable portions of dataclasses_descriptors test instead.
1 parent 871c2f0 commit 6d2f52c

6 files changed

Lines changed: 16 additions & 114 deletions

File tree

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
conformant = "Partial"
2-
notes = """
3-
Assumes descriptor behavior only when field is assigned in class body.
4-
Does not correctly evaluate type of descriptor access.
5-
"""
61
output = """
7-
dataclasses_descriptors.py:61: error: Cannot access instance-only attribute "x" on class object [misc]
8-
dataclasses_descriptors.py:62: error: Cannot access instance-only attribute "y" on class object [misc]
9-
dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type]
10-
dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type]
112
"""
12-
conformance_automated = "Fail"
3+
conformance_automated = "Pass"
134
errors_diff = """
14-
Line 61: Unexpected errors ['dataclasses_descriptors.py:61: error: Cannot access instance-only attribute "x" on class object [misc]']
15-
Line 62: Unexpected errors ['dataclasses_descriptors.py:62: error: Cannot access instance-only attribute "y" on class object [misc]']
16-
Line 66: Unexpected errors ['dataclasses_descriptors.py:66: error: Expression is of type "Desc2[int]", not "int" [assert-type]']
17-
Line 67: Unexpected errors ['dataclasses_descriptors.py:67: error: Expression is of type "Desc2[str]", not "str" [assert-type]']
185
"""
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
conformant = "Partial"
2-
notes = """
3-
Conformance suite is questionable; see <https://github.com/python/typing/issues/2259>
4-
"""
5-
conformance_automated = "Fail"
1+
conformance_automated = "Pass"
62
errors_diff = """
7-
Line 61: Unexpected errors ['./dataclasses_descriptors.py:61:12: Any[error] is not equivalent to list[int]', "./dataclasses_descriptors.py:61:12: <class 'DC2'> has no attribute 'x' [undefined_attribute]"]
8-
Line 62: Unexpected errors ['./dataclasses_descriptors.py:62:12: Any[error] is not equivalent to list[str]', "./dataclasses_descriptors.py:62:12: <class 'DC2'> has no attribute 'y' [undefined_attribute]"]
9-
Line 63: Unexpected errors ['./dataclasses_descriptors.py:63:12: list[Any[generic_argument]] is not equivalent to list[str]']
10-
Line 66: Unexpected errors ['./dataclasses_descriptors.py:66:12: ./dataclasses_descriptors.py.Desc2[int] is not equivalent to int']
11-
Line 67: Unexpected errors ['./dataclasses_descriptors.py:67:12: ./dataclasses_descriptors.py.Desc2[str] is not equivalent to str']
12-
Line 68: Unexpected errors ['./dataclasses_descriptors.py:68:12: Any[generic_argument] is not equivalent to str']
133
"""
144
output = """
15-
./dataclasses_descriptors.py:61:12: Any[error] is not equivalent to list[int]
16-
./dataclasses_descriptors.py:61:12: <class 'DC2'> has no attribute 'x' [undefined_attribute]
17-
./dataclasses_descriptors.py:62:12: Any[error] is not equivalent to list[str]
18-
./dataclasses_descriptors.py:62:12: <class 'DC2'> has no attribute 'y' [undefined_attribute]
19-
./dataclasses_descriptors.py:63:12: list[Any[generic_argument]] is not equivalent to list[str]
20-
./dataclasses_descriptors.py:66:12: ./dataclasses_descriptors.py.Desc2[int] is not equivalent to int
21-
./dataclasses_descriptors.py:67:12: ./dataclasses_descriptors.py.Desc2[str] is not equivalent to str
22-
./dataclasses_descriptors.py:68:12: Any[generic_argument] is not equivalent to str
235
"""
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
conformant = "Partial"
2-
notes = """
3-
Assumes descriptor behavior only when field is assigned in class body
4-
Doesn't allow non-data descriptors or data descriptors with differing `__get__` and `__set__` types
5-
"""
6-
conformance_automated = "Fail"
1+
conformance_automated = "Pass"
72
errors_diff = """
8-
Line 58: Unexpected errors ['Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor]']
93
"""
104
output = """
11-
ERROR dataclasses_descriptors.py:58:5-6: Cannot set field `z` to non-data descriptor `Desc2` [bad-dataclass-descriptor]
125
"""

‎conformance/results/results.html‎

Lines changed: 12 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
conformance_automated = "Fail"
2-
conformant = "Partial"
3-
notes = """
4-
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.
5-
"""
1+
conformance_automated = "Pass"
62
errors_diff = """
7-
Line 66: Unexpected errors ['dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int | Desc2[int]` does not match asserted type `int`']
8-
Line 67: Unexpected errors ['dataclasses_descriptors.py:67:1: error[type-assertion-failure] Type `str | Desc2[str]` does not match asserted type `str`']
93
"""
104
output = """
11-
dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int | Desc2[int]` does not match asserted type `int`
12-
dataclasses_descriptors.py:67:1: error[type-assertion-failure] Type `str | Desc2[str]` does not match asserted type `str`
135
"""

‎conformance/tests/dataclasses_descriptors.py‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,3 @@ class DC1:
3636

3737
assert_type(dc1.y, int)
3838
assert_type(DC1.y, Desc1)
39-
40-
41-
class Desc2(Generic[T]):
42-
@overload
43-
def __get__(self, instance: None, owner: Any) -> list[T]:
44-
...
45-
46-
@overload
47-
def __get__(self, instance: object, owner: Any) -> T:
48-
...
49-
50-
def __get__(self, instance: object | None, owner: Any) -> list[T] | T:
51-
raise NotImplementedError
52-
53-
54-
@dataclass
55-
class DC2:
56-
x: Desc2[int]
57-
y: Desc2[str]
58-
z: Desc2[str] = Desc2()
59-
60-
61-
assert_type(DC2.x, list[int])
62-
assert_type(DC2.y, list[str])
63-
assert_type(DC2.z, list[str])
64-
65-
dc2 = DC2(Desc2(), Desc2(), Desc2())
66-
assert_type(dc2.x, int)
67-
assert_type(dc2.y, str)
68-
assert_type(dc2.z, str)

0 commit comments

Comments
 (0)