@@ -13,7 +13,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/instance_layout_conflict
1313## mdtest_snippet .py
1414
1515` ` `
16- 1 | from typing_extensions import disjoint_base
16+ 1 | from typing_extensions import Protocol, TypedDict, disjoint_base
1717 2 |
1818 3 | # fmt: off
1919 4 |
@@ -43,15 +43,19 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/instance_layout_conflict
434328 |
444429 | @disjoint_base
454530 | class H: ...
46- 31 |
47- 32 | class I( # error: [instance-layout-conflict]
48- 33 | G,
49- 34 | H
50- 35 | ): ...
51- 36 |
52- 37 | # fmt: on
53- 38 | # error: [invalid-generic-class]
54- 39 | class Foo(range, str): ... # error: [subclass-of-final-class]
46+ 31 | @disjoint_base # error: [invalid-typed-dict-header] "` @disjoint_base ` cannot be used with ` TypedDict ` class ` Movie ` "
47+ 32 | class Movie(TypedDict):
48+ 33 | name: str
49+ 34 | @disjoint_base # error: [invalid-protocol] "` @disjoint_base ` cannot be used with protocol class ` SupportsClose ` "
50+ 35 | class SupportsClose(Protocol):
51+ 36 | def close(self) -> None: ...
52+ 37 | class I( # error: [instance-layout-conflict]
53+ 38 | G,
54+ 39 | H
55+ 40 | ): ...
56+ 41 | # fmt: on
57+ 42 | # error: [invalid-generic-class]
58+ 43 | class Foo(range, str): ... # error: [subclass-of-final-class]
5559` ` `
5660
5761# Diagnostics
@@ -144,33 +148,53 @@ info: Two classes cannot coexist in a class's MRO if their instances have incomp
144148
145149` ` `
146150
151+ ` ` `
152+ error[invalid-typed-dict-header]: ` @disjoint_base ` cannot be used with ` TypedDict ` class ` Movie `
153+ --> src/mdtest_snippet.py:31:1
154+ |
155+ 31 | @disjoint_base # error: [invalid-typed-dict-header] "` @disjoint_base ` cannot be used with ` TypedDict ` class ` Movie ` "
156+ | ^^^^^^^^^^^^^^
157+ |
158+
159+ ` ` `
160+
161+ ` ` `
162+ error[invalid-protocol]: ` @disjoint_base ` cannot be used with protocol class ` SupportsClose `
163+ --> src/mdtest_snippet.py:34:1
164+ |
165+ 34 | @disjoint_base # error: [invalid-protocol] "` @disjoint_base ` cannot be used with protocol class ` SupportsClose ` "
166+ | ^^^^^^^^^^^^^^
167+ |
168+
169+ ` ` `
170+
147171` ` `
148172error[instance-layout-conflict]: Class will raise ` TypeError ` at runtime due to incompatible bases
149- --> src/mdtest_snippet.py:32 :7
173+ --> src/mdtest_snippet.py:37 :7
150174 |
151- 32 | class I( # error: [instance-layout-conflict]
175+ 37 | class I( # error: [instance-layout-conflict]
152176 | _______^
153- 33 | | G,
154- 34 | | H
155- 35 | | ): ...
177+ 38 | | G,
178+ 39 | | H
179+ 40 | | ): ...
156180 | |_^ Bases ` G ` and ` H ` cannot be combined in multiple inheritance
157181 |
158182info: Two classes cannot coexist in a class's MRO if their instances have incompatible memory layouts
159- --> src/mdtest_snippet.py:33 :5
183+ --> src/mdtest_snippet.py:38 :5
160184 |
161- 33 | G,
185+ 38 | G,
162186 | - ` G ` instances have a distinct memory layout because of the way ` G ` is implemented in a C extension
163- 34 | H
187+ 39 | H
164188 | - ` H ` instances have a distinct memory layout because of the way ` H ` is implemented in a C extension
165189 |
166190
167191` ` `
168192
169193` ` `
170194error[invalid-generic-class]: Inconsistent type arguments for ` Sequence ` among class bases
171- --> src/mdtest_snippet.py:39 :7
195+ --> src/mdtest_snippet.py:43 :7
172196 |
173- 39 | class Foo(range, str): ... # error: [subclass-of-final-class]
197+ 43 | class Foo(range, str): ... # error: [subclass-of-final-class]
174198 | ^^^^-----^^---^
175199 | | |
176200 | | Later class base inherits from ` Sequence [str ]`
@@ -181,9 +205,9 @@ error[invalid-generic-class]: Inconsistent type arguments for `Sequence` among c
181205
182206` ` `
183207error[subclass-of-final-class]: Class ` Foo ` cannot inherit from final class ` range `
184- --> src/mdtest_snippet.py:39 :11
208+ --> src/mdtest_snippet.py:43 :11
185209 |
186- 39 | class Foo(range, str): ... # error: [subclass-of-final-class]
210+ 43 | class Foo(range, str): ... # error: [subclass-of-final-class]
187211 | ^^^^^
188212 |
189213
0 commit comments