Conversation
187745a to
7b7df01
Compare
Previously we considered the else branch in the test case here unreachable
7b7df01 to
f69eb3b
Compare
This comment has been minimized.
This comment has been minimized.
|
mesonbuild is desirable. the line is already type ignored because it is unsafe, now we get a better error message |
| [builtins fixtures/tuple.pyi] | ||
|
|
||
|
|
||
| [case testTypeIsGeneric] |
There was a problem hiding this comment.
This is #20330 . The regression meant we only accepted negative
| if is_async_callable(f): | ||
| reveal_type(f) # N: Revealed type is "(def (*Any, **Any) -> typing.Awaitable[Any]) | (def () -> typing.Awaitable[builtins.int])" | ||
| else: | ||
| reveal_type(f) # N: Revealed type is "def () -> builtins.int | typing.Awaitable[builtins.int]" |
There was a problem hiding this comment.
This is essentially the starlette code. On master the else branch narrowing doesn't happen.
| # ...but not regular subtyping relationships | ||
| if isinstance(x, FloatLike): | ||
| reveal_type(x) # N: Revealed type is "__main__.FloatLike | __main__.IntLike" | ||
| reveal_type(x) # N: Revealed type is "__main__.FloatLike" |
There was a problem hiding this comment.
Not fully clear what this was testing. The change here is just that we simplify the union. I think the real thing this wants to test is that the else branch is unreachable, so I added that
96eba9b to
9304905
Compare
|
Diff from mypy_primer, showing the effect of this PR on open source code: starlette (https://github.com/encode/starlette)
- starlette/middleware/errors.py:178: error: Argument 1 to "run_in_threadpool" has incompatible type "Callable[[Request[State], Exception], Response | Awaitable[Response]] | Callable[[WebSocket, Exception], Awaitable[None]]"; expected "Callable[[Request[State], Exception], Response]" [arg-type]
+ starlette/middleware/errors.py:178: error: Argument 1 to "run_in_threadpool" has incompatible type "Callable[[Request[State], Exception], Response | Awaitable[Response]]"; expected "Callable[[Request[State], Exception], Response]" [arg-type]
- starlette/_exception_handler.py:61: error: Argument 1 to "run_in_threadpool" has incompatible type "Callable[[Request[State], Exception], Response | Awaitable[Response]] | Callable[[WebSocket, Exception], Awaitable[None]]"; expected "Callable[[Request[State] | WebSocket, Exception], Any | None]" [arg-type]
+ starlette/_exception_handler.py:61: error: Argument 2 to "run_in_threadpool" has incompatible type "Request[State] | WebSocket"; expected "Request[State]" [arg-type]
core (https://github.com/home-assistant/core)
+ homeassistant/components/config/entity_registry.py:231: error: Invalid index type "Literal['aliases']" for "dict[Literal['device_class', 'disabled_by', 'hidden_by', 'icon', 'name', 'new_entity_id', 'area_id'], Any]"; expected type "Literal['device_class', 'disabled_by', 'hidden_by', 'icon', 'name', 'new_entity_id', 'area_id']" [index]
+ homeassistant/components/config/entity_registry.py:235: error: Invalid index type "Literal['labels']" for "dict[Literal['device_class', 'disabled_by', 'hidden_by', 'icon', 'name', 'new_entity_id', 'area_id'], Any]"; expected type "Literal['device_class', 'disabled_by', 'hidden_by', 'icon', 'name', 'new_entity_id', 'area_id']" [index]
+ homeassistant/components/config/entity_registry.py:260: error: Invalid index type "Literal['categories']" for "dict[Literal['device_class', 'disabled_by', 'hidden_by', 'icon', 'name', 'new_entity_id', 'area_id'], Any]"; expected type "Literal['device_class', 'disabled_by', 'hidden_by', 'icon', 'name', 'new_entity_id', 'area_id']" [index]
- homeassistant/components/huawei_lte/__init__.py:192: error: Right operand of "and" is never evaluated [unreachable]
meson (https://github.com/mesonbuild/meson)
+ mesonbuild/modules/rust.py:189: error: Unused "type: ignore" comment [unused-ignore]
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "prelink" [typeddict-item]
+ mesonbuild/modules/rust.py:189:39: note: Error code "typeddict-item" not covered by "type: ignore" comment
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "rust_abi" [typeddict-item]
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "version" [typeddict-item]
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "soversion" [typeddict-item]
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "darwin_versions" [typeddict-item]
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "shortname" [typeddict-item]
+ mesonbuild/modules/rust.py:189:39: error: TypedDict "ExecutableKeywordArguments" has no key "pic" [typeddict-item]
|
Previously we considered the else branch unreachable in the
testNarrowingAnyUniontest case. It's also nice that the new code is more obviously correctFixes #20330
This will help with landing #20727 as well