File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
crates/ty_python_semantic/resources/mdtest/narrow Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -146,23 +146,19 @@ def _(x: A | B):
146146
147147## No special narrowing for custom ` type ` callable
148148
149- ` stub.pyi ` :
150-
151- ``` pyi
152- from ty_extensions import TypeOf
153-
154- def type (x : object ) -> TypeOf[int ]: ...
155- ```
156-
157149``` py
158- from stub import type
150+ def type (x : object ):
151+ return int
159152
160153class A : ...
161154class B : ...
162155
163156def _ (x : A | B):
157+ # The custom `type` function always returns `int`,
158+ # so any branch other than `type(...) is int` is unreachable.
164159 if type (x) is A:
165160 reveal_type(x) # revealed: Never
161+ # And the condition here is always `True` and has no effect on the narrowing of `x`.
166162 elif type (x) is int :
167163 reveal_type(x) # revealed: A | B
168164 else :
You can’t perform that action at this time.
0 commit comments