fix False positive [not-iterable] for dict literal with heterogeneous values built in a loop #2798#3317
fix False positive [not-iterable] for dict literal with heterogeneous values built in a loop #2798#3317asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a type inference edge case for dict literals used as values inside another dict that’s being built up in a loop, which previously could cause a false-positive [not-iterable] when accessing and iterating over a list stored under a different key.
Changes:
- Ignore a bare, unconstrained partial type hint when inferring a dict literal, allowing heterogeneous inner dict literals to be inferred precisely (e.g., as an anonymous TypedDict-like shape) before being pinned by the outer assignment.
- Add a regression test covering the reported loop-assigned heterogeneous inner dict scenario (Issue #2798).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyrefly/lib/alt/expr.rs |
Filters out a bare partial-hint during dict literal inference to avoid collapsing heterogeneous inner dict values incorrectly. |
pyrefly/lib/test/dict.rs |
Adds a regression testcase reproducing the reported false-positive [not-iterable] scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Diff from mypy_primer, showing the effect of this PR on open source code: jax (https://github.com/google/jax)
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cpu_triangular_solve_blas_trsm.py:114:26-151:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cpu_tridiagonal_solve_lapack_gtsv.py:158:26-233:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_cholesky_solver_potrf.py:160:26-231:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_eigh_cusolver_syev.py:183:26-271:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[()] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_lu_cusolver_getrf.py:115:26-157:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[()] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_qr_cusolver_geqrf.py:158:26-218:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[()] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_svd_cusolver_gesvd.py:187:36-283:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_tridiagonal_cusolver_sytrd.py:182:26-269:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/gpu_eigh_solver_syev.py:271:26-406:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[()] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_cholesky_solver_potrf.py:160:26-231:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_lu_rocsolver_getrf.py:125:26-170:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[()] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_qr_hipsolver_geqrf.py:156:26-213:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[()] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_svd_hipsolver_gesvd.py:192:36-289:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
- ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_tridiagonal_hipsolver_sytrd.py:178:26-262:2: Cannot set item in `dict[str, dict[str, bytes | date | int | list[str] | str | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]] | tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]]]` [unsupported-operation]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cpu_triangular_solve_blas_trsm.py:119:12-125:73: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cpu_triangular_solve_blas_trsm.py:126:22-133:65: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cpu_tridiagonal_solve_lapack_gtsv.py:163:12-189:55: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cpu_tridiagonal_solve_lapack_gtsv.py:190:22-206:60: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_cholesky_solver_potrf.py:165:12-172:77: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_cholesky_solver_potrf.py:173:22-181:25: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_eigh_cusolver_syev.py:189:22-197:22: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_lu_cusolver_getrf.py:121:22-123:130: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_qr_cusolver_geqrf.py:164:22-178:24: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_svd_cusolver_gesvd.py:192:12-209:25: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_svd_cusolver_gesvd.py:210:22-245:24: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_tridiagonal_cusolver_sytrd.py:187:12-204:25: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/cuda_tridiagonal_cusolver_sytrd.py:205:22-227:51: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/gpu_eigh_solver_syev.py:277:20-306:4: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_cholesky_solver_potrf.py:165:12-173:25: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_cholesky_solver_potrf.py:174:22-181:75: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_lu_rocsolver_getrf.py:131:22-133:130: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]], ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_qr_hipsolver_geqrf.py:162:22-176:24: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_svd_hipsolver_gesvd.py:197:12-214:25: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_svd_hipsolver_gesvd.py:215:22-250:24: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_tridiagonal_hipsolver_sytrd.py:183:12-200:25: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `inputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
+ ERROR jax/_src/internal_test_util/export_back_compat_test_data/rocm_tridiagonal_hipsolver_sytrd.py:201:22-224:51: `tuple[ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[complexfloating[_32Bit, _32Bit]]]]` is not assignable to TypedDict key `expected_outputs` with type `tuple[ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]], ndarray[tuple[Any, ...], dtype[floating[_32Bit]]]]` [bad-typed-dict-key]
cryptography (https://github.com/pyca/cryptography)
- ERROR tests/utils.py:415:34-60: Cannot set item in `dict[str, int | str]` [unsupported-operation]
- ERROR tests/utils.py:419:17-425:18: Argument `dict[str, bytes | int | str]` is not assignable to parameter `object` with type `dict[str, int | str]` in function `list.append` [bad-argument-type]
+ ERROR tests/utils.py:415:34-60: `bytes` is not assignable to TypedDict key `msg` with type `int | str` [bad-typed-dict-key]
+ ERROR tests/utils.py:424:28-54: `bytes` is not assignable to TypedDict key with type `int | str` [bad-typed-dict-key]
apprise (https://github.com/caronc/apprise)
- ERROR apprise/config/base.py:806:38-52: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:806:38-52: Cannot index into `str` [bad-index]
- ERROR apprise/config/base.py:808:21-35: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:808:21-35: Cannot index into `str` [bad-index]
- ERROR apprise/config/base.py:813:32-49: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:813:32-49: Cannot index into `str` [bad-index]
- ERROR apprise/config/base.py:818:40-56: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:818:40-56: Cannot index into `str` [bad-index]
- ERROR apprise/config/base.py:1324:38-52: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:1326:21-35: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:1332:32-49: Cannot index into `int` [bad-index]
- ERROR apprise/config/base.py:1337:40-56: Cannot index into `int` [bad-index]
+ ERROR apprise/plugins/pushover.py:430:17-434:18: Unpacked `dict[str, str | Unknown | None]` is not assignable to `dict[str, str | Unknown | None]` [bad-unpacking]
+ ERROR apprise/plugins/pushover.py:438:17-441:18: Unpacked `dict[str, str | Unknown | None]` is not assignable to `dict[str, str | Unknown | None]` [bad-unpacking]
zulip (https://github.com/zulip/zulip)
+ ERROR zerver/lib/dev_ldap_directory.py:42:65-47:14: Unpacked `dict[str, list[str]]` is not assignable to `dict[str, list[bytes] | list[str]]` [bad-unpacking]
+ ERROR zerver/lib/dev_ldap_directory.py:49:74-53:14: Unpacked `dict[str, list[str]]` is not assignable to `dict[str, list[bytes] | list[str]]` [bad-unpacking]
+ ERROR zerver/lib/dev_ldap_directory.py:55:74-57:14: Unpacked `dict[str, list[str]]` is not assignable to `dict[str, list[bytes] | list[str]]` [bad-unpacking]
pywin32 (https://github.com/mhammond/pywin32)
- ERROR win32/Demos/security/explicit_entries.py:128:26-35: Argument `list[dict[str, dict[str, Unknown | None] | int]]` is not assignable to parameter `obexpl_list` with type `tuple[dict[str, dict[str, PySID | int] | int], ...]` in function `_win32typing.PyACL.SetEntriesInAcl` [bad-argument-type]
+ ERROR win32/Demos/security/explicit_entries.py:128:26-35: Argument `list[dict[str, dict[str, Unknown | None] | int | Unknown]]` is not assignable to parameter `obexpl_list` with type `tuple[dict[str, dict[str, PySID | int] | int], ...]` in function `_win32typing.PyACL.SetEntriesInAcl` [bad-argument-type]
- ERROR win32/Demos/security/explicit_entries.py:165:26-35: Argument `list[dict[str, dict[str, Unknown | None] | int]]` is not assignable to parameter `obexpl_list` with type `tuple[dict[str, dict[str, PySID | int] | int], ...]` in function `_win32typing.PyACL.SetEntriesInAcl` [bad-argument-type]
+ ERROR win32/Demos/security/explicit_entries.py:165:26-35: Argument `list[dict[str, dict[str, Unknown | None] | int | Unknown]]` is not assignable to parameter `obexpl_list` with type `tuple[dict[str, dict[str, PySID | int] | int], ...]` in function `_win32typing.PyACL.SetEntriesInAcl` [bad-argument-type]
core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/diagnostics/__init__.py:217:29-40: `list[dict[str, Any]]` is not assignable to TypedDict key `issues` with type `Mapping[str | None, dict[SetupPhases, float]] | Mapping[str, Any] | dict[str, dict[str, list[str] | str | None]] | dict[str, Any] | Manifest` [bad-typed-dict-key]
+ ERROR homeassistant/components/diagnostics/__init__.py:217:29-40: `list[dict[str, Any]]` is not assignable to TypedDict key `issues` with type `Mapping[str | None, dict[SetupPhases, float]] | Mapping[str, Any] | dict[str, dict[str, list[str] | str | Unknown | None]] | dict[str, Any] | Manifest` [bad-typed-dict-key]
- ERROR homeassistant/components/websocket_api/commands.py:1143:27-62: Cannot set item in `dict[str, dict[str, bool | None]]` [unsupported-operation]
spark (https://github.com/apache/spark)
- ERROR python/pyspark/pandas/tests/groupby/test_describe.py:34:22-76: Argument `dict[str, list[int] | list[str]]` is not assignable to parameter `object` with type `dict[str, list[int]]` in function `list.append` [bad-argument-type]
+ ERROR python/pyspark/pandas/tests/groupby/test_describe.py:34:28-43: `list[str]` is not assignable to TypedDict key `a` with type `list[int]` [bad-typed-dict-key]
- ERROR python/pyspark/pandas/tests/groupby/test_describe.py:70:22-82: Argument `dict[str, list[int] | list[str]]` is not assignable to parameter `object` with type `dict[str, list[str]]` in function `list.append` [bad-argument-type]
+ ERROR python/pyspark/pandas/tests/groupby/test_describe.py:70:50-59: `list[int]` is not assignable to TypedDict key `b` with type `list[str]` [bad-typed-dict-key]
|
Primer Diff Classification❌ 2 regression(s) | ✅ 2 improvement(s) | ➖ 3 neutral | 7 project(s) total | +34, -30 errors 2 regression(s) across jax, zulip. error kinds:
Detailed analysis❌ Regression (2)jax (+22, -14)
zulip (+3)
✅ Improvement (2)apprise (+2, -8)
Per-category reasoning:
core (+1, -2)
➖ Neutral (3)cryptography (+2, -2)
The code in Old errors (removed):
New errors (added):
The code is valid — Overall this is a wash: 2 false positives replaced by 2 different false positives. The new errors are arguably more confusing since they reference TypedDict semantics for plain dicts, though they are more localized than the old cascading
pywin32 (+2, -2)
spark (+2, -2)
Suggested fixesSummary: The PR's partial hint filter for dict literals causes pyrefly to infer anonymous TypedDicts for plain dict() calls and dict literals, producing 25+ false positive bad-typed-dict-key and bad-unpacking errors across jax, zulip, apprise, and other projects. 1. In the dict expression handler in
Was this helpful? React with 👍 or 👎 Classification by primer-classifier (1 heuristic, 6 LLM) |
|
@grievejia has imported this pull request. If you are a Meta employee, you can view this in D104256983. |
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
rchen152
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
rchen152
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary
Fixes #2798
dict literals ignore a bare unconstrained partial hint.
That lets the inner heterogeneous literal form an anonymous TypedDict first, then the surrounding assignment pins the partial container type to that precise result instead of collapsing it
Test Plan
add test