| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Previously we considered the else branch in the test case here unreachable
|
mesonbuild is desirable. the line is already type ignored because it is unsafe, now we get a better error message |
Sorry, something went wrong.
| [builtins fixtures/tuple.pyi] | ||
|
|
||
|
|
||
| [case testTypeIsGeneric] |
There was a problem hiding this comment.
This is #20330 . The regression meant we only accepted negative
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
| # ...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
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, I think the else part is the important one. Not simplifying the union is an implementation detail, the two types are equivalent.
Sorry, something went wrong.
|
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]
|
Sorry, something went wrong.
|
Planning on merging this soon, since it is a prerequisite for some changes that need to be landed to unblock a release |
Sorry, something went wrong.
There was a problem hiding this comment.
LG.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Previously we considered the else branch unreachable in the testNarrowingAnyUnion test case. It's also nice that the new code is more obviously correct
Fixes #20330
This will help with landing #20727 as well