Skip to content

try fix more generic way for set and dict #3265 - #4877

Open
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3265
Open

try fix more generic way for set and dict #3265#4877
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3265

Conversation

@asukaminato0721

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3265

Moved the fix into the shared solver.

Any in a generic bound no longer becomes a contextual hint that erases inferred element types.

Test Plan

add test

@meta-codesync

meta-codesync Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D119446581. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on open source code:

============================================================
SUMMARY
============================================================
Total: +8 new errors, -13 fixed errors
By preset: +4/-4 (default), +5/-13 (strict)

Projects with changes (5):
  cki-lib: +1 -1
  rotki: +0 -7
  zope.interface: +3 -4
  core: +2 -1
  sphinx: +2 -0
============================================================

FULL DIFF DETAILS
------------------------------------------------------------

cki-lib (https://gitlab.com/cki-project/cki-lib)
- ERROR cki_lib/metrics/server.py:23:12-24: Returned type `Iterator[Any] | Iterator[Unknown]` is not assignable to declared return type `None` [bad-return]
+ ERROR cki_lib/metrics/server.py:23:12-24: Returned type `Iterator[Unknown]` is not assignable to declared return type `None` [bad-return]

rotki (https://github.com/rotki/rotki)
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:341:27-29: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:345:36-38: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:364:27-29: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:368:36-38: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:387:27-29: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:391:36-38: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR rotkehlchen/tests/exchanges/test_coinbaseprime.py:414:36-38: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]

zope.interface (https://github.com/zopefoundation/zope.interface)
- ERROR src/zope/interface/common/tests/test_collections.py:118:19-21: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR src/zope/interface/common/tests/test_collections.py:122:23-25: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR src/zope/interface/common/tests/test_collections.py:118:46-48: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR src/zope/interface/common/tests/test_collections.py:135:22-38: Cannot set item in `dict[type[IItemsView] | type[IKeysView] | type[IValuesView] | type[MappingProxyType] | type[UserString] | type[memoryview] | type[range] | str | type[Generator[int] | Iterator[LiteralString] | Iterator[int] | Iterator[tuple[Unknown, Unknown]] | Iterator[Any] | Iterator[Unknown]], (() -> Generator[int]) | (() -> Iterator[LiteralString]) | (() -> Iterator[int]) | (() -> Iterator[tuple[Unknown, Unknown]]) | (() -> Iterator[Any]) | (() -> Iterator[Unknown]) | (() -> MappingProxyType[Unknown, Unknown]) | (() -> UserString) | (() -> memoryview) | (() -> range) | (() -> dict_items[Unknown, Unknown]) | (() -> dict_keys[Unknown, Unknown]) | (() -> dict_values[Unknown, Unknown]) | type[SkipTest]]` [unsupported-operation]
+ ERROR src/zope/interface/common/tests/test_collections.py:135:22-38: Cannot set item in `dict[type[IItemsView] | type[IKeysView] | type[IValuesView] | type[MappingProxyType] | type[UserString] | type[memoryview] | type[range] | str | type[Generator[int] | Iterator[LiteralString] | Iterator[int] | Iterator[tuple[Any, Any]] | Iterator[Any] | Iterator[Unknown]], (() -> Generator[int]) | (() -> Iterator[LiteralString]) | (() -> Iterator[int]) | (() -> Iterator[tuple[Any, Any]]) | (() -> Iterator[Any]) | (() -> Iterator[Unknown]) | (() -> MappingProxyType[Unknown, Unknown]) | (() -> UserString) | (() -> memoryview) | (() -> range) | (() -> dict_items[Unknown, Unknown]) | (() -> dict_keys[Unknown, Unknown]) | (() -> dict_values[Unknown, Unknown]) | type[SkipTest]]` [unsupported-operation]
- ERROR src/zope/interface/common/tests/test_collections.py:135:42-70: Cannot set item in `dict[type[IItemsView] | type[IKeysView] | type[IValuesView] | type[MappingProxyType] | type[UserString] | type[memoryview] | type[range] | str | type[Generator[int] | Iterator[LiteralString] | Iterator[int] | Iterator[tuple[Unknown, Unknown]] | Iterator[Any] | Iterator[Unknown]], (() -> Generator[int]) | (() -> Iterator[LiteralString]) | (() -> Iterator[int]) | (() -> Iterator[tuple[Unknown, Unknown]]) | (() -> Iterator[Any]) | (() -> Iterator[Unknown]) | (() -> MappingProxyType[Unknown, Unknown]) | (() -> UserString) | (() -> memoryview) | (() -> range) | (() -> dict_items[Unknown, Unknown]) | (() -> dict_keys[Unknown, Unknown]) | (() -> dict_values[Unknown, Unknown]) | type[SkipTest]]` [unsupported-operation]
+ ERROR src/zope/interface/common/tests/test_collections.py:135:42-70: Cannot set item in `dict[type[IItemsView] | type[IKeysView] | type[IValuesView] | type[MappingProxyType] | type[UserString] | type[memoryview] | type[range] | str | type[Generator[int] | Iterator[LiteralString] | Iterator[int] | Iterator[tuple[Any, Any]] | Iterator[Any] | Iterator[Unknown]], (() -> Generator[int]) | (() -> Iterator[LiteralString]) | (() -> Iterator[int]) | (() -> Iterator[tuple[Any, Any]]) | (() -> Iterator[Any]) | (() -> Iterator[Unknown]) | (() -> MappingProxyType[Unknown, Unknown]) | (() -> UserString) | (() -> memoryview) | (() -> range) | (() -> dict_items[Unknown, Unknown]) | (() -> dict_keys[Unknown, Unknown]) | (() -> dict_values[Unknown, Unknown]) | type[SkipTest]]` [unsupported-operation]

core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/min_max/sensor.py:259:57-261:14: `Event[dict[str, Any]]` is not assignable to `Event[EventStateChangedData]` [bad-assignment]
+ ERROR homeassistant/components/min_max/sensor.py:259:57-261:14: `Event[dict[str, State | str | None]]` is not assignable to `Event[EventStateChangedData]` [bad-assignment]
+ ERROR homeassistant/components/pilight/__init__.py:131:37-46: The type of this argument is unknown [unknown-argument-type]

sphinx (https://github.com/sphinx-doc/sphinx)
+ ERROR sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2078:17-68: The type of this argument is unknown [unknown-argument-type]
+ ERROR sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2730:21-72: The type of this argument is unknown [unknown-argument-type]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pyrefly infers Iterator[Any] instead of Iterator[int] for iter([0])

2 participants