[ty] Type-context aware literal promotion by ibraheemdev · Pull Request #20776 · astral-sh/ruff (original) (raw)
mypy_primer results
Changes were detected when running on open source projects
porcupine (https://github.com/Akuli/porcupine)
- porcupine/plugins/longlinemarker.py:56:17: error[invalid-assignment] Object of type
list[Unknown | str]is not assignable tolist[Literal["bgcolor", "color", "border"]] - Found 24 diagnostics
- Found 23 diagnostics
pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_generate_schema.py:1967:9: error[invalid-assignment] Object of type
dict[Unknown | _ParameterKind, Unknown | str]is not assignable todict[_ParameterKind, Literal["positional_only", "positional_or_keyword", "keyword_only"]] - pydantic/_internal/_generate_schema.py:2041:9: error[invalid-assignment] Object of type
dict[Unknown | _ParameterKind, Unknown | str]is not assignable todict[_ParameterKind, Literal["positional_only", "positional_or_keyword", "var_args", "keyword_only"]] - Found 768 diagnostics
- Found 766 diagnostics
freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/exchange/binance.py:54:37: error[invalid-argument-type] Invalid argument to key "order_props_in_contracts" with declared type
list[Literal["amount", "cost", "filled", "remaining"]]on TypedDictFtHas: value of typelist[str] - freqtrade/exchange/exchange.py:161:37: error[invalid-argument-type] Invalid argument to key "order_props_in_contracts" with declared type
list[Literal["amount", "cost", "filled", "remaining"]]on TypedDictFtHas: value of typelist[str] - Found 404 diagnostics
- Found 402 diagnostics
meson (https://github.com/mesonbuild/meson)
- mesonbuild/modules/_qt.py:941:9: error[invalid-assignment] Object of type
list[Unknown | bool]is not assignable tolist[str | Literal[False]] - Found 887 diagnostics
- Found 886 diagnostics
discord.py (https://github.com/Rapptz/discord.py)
- discord/ui/select.py:1227:13: error[invalid-assignment] Object of type
dict[Unknown | <class 'UserSelect'> | <class 'RoleSelect'> | <class 'MentionableSelect'> | <class 'ChannelSelect'>, Unknown | ComponentType]is not assignable todict[type[BaseSelect[Unknown]], Literal[ComponentType.user_select, ComponentType.channel_select, ComponentType.role_select, ComponentType.mentionable_select]] - Found 509 diagnostics
- Found 508 diagnostics
sphinx (https://github.com/sphinx-doc/sphinx)
- sphinx/environment/init.py:94:1: error[invalid-assignment] Object of type
dict[Unknown | str, Unknown | bool | ((node: Node) -> bool)]is not assignable todict[str, Literal[False] | ((Node, /) -> bool)] - Found 493 diagnostics
- Found 492 diagnostics
pyodide (https://github.com/pyodide/pyodide)
- pyodide-build/pyodide_build/recipe/skeleton.py:359:47: error[invalid-argument-type] Argument to function
_find_distis incorrect: Expectedlist[Literal["wheel", "sdist"]], foundlist[Unknown | str] - Found 986 diagnostics
- Found 985 diagnostics
openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/book_providers.py:747:9: error[invalid-argument-type] Argument to function
multisort_bestis incorrect: Expectedlist[tuple[Literal["min", "max"], (@Todo, /) -> int | float]], foundlist[Unknown | tuple[str, (rec) -> Unknown]] - Found 850 diagnostics
- Found 849 diagnostics
prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-aws/prefect_aws/observers/ecs.py:44:1: error[invalid-assignment] Object of type
dict[Unknown | str, Unknown | str]is not assignable todict[str, Literal["task", "container-instance", "deployment"]] - Found 3203 diagnostics
- Found 3202 diagnostics
pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/lib/zig.py:17:1: error[invalid-assignment] Object of type
dict[Unknown | tuple[str, str, int], Unknown | str]is not assignable todict[tuple[@Todo, Literal["little", "big"], int], str] - Found 2581 diagnostics
- Found 2580 diagnostics
colour (https://github.com/colour-science/colour)
- colour/notation/munsell.py:2037:5: error[invalid-assignment] Object of type
dict[Unknown | int, Unknown | None | str]is not assignable todict[int, Literal["Linear", "Radial"] | None] - Found 479 diagnostics
- Found 478 diagnostics
streamlit (https://github.com/streamlit/streamlit)
- lib/streamlit/config.py:1189:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1205:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1220:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1235:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1250:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1265:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1287:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1309:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1331:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1353:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1375:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1396:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1418:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1439:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1460:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1481:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1502:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1523:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1544:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1565:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1586:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1607:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1628:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1649:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1670:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1691:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1712:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1727:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1743:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1763:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1778:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1807:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1838:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1852:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1866:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1893:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1932:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1969:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:1994:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2014:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2036:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2062:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2090:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2105:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2122:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2143:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2159:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2170:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - lib/streamlit/config.py:2213:5: error[invalid-argument-type] Argument to function
_create_theme_optionsis incorrect: Expectedlist[Literal["theme"] | CustomThemeCategories], foundlist[Unknown | str] - Found 194 diagnostics
- Found 145 diagnostics
pandas (https://github.com/pandas-dev/pandas)
- pandas/core/frame.py:14046:5: error[invalid-assignment] Object of type
list[Unknown | str]is not assignable tolist[Literal["index", "columns"]] - pandas/core/generic.py:5417:9: error[invalid-assignment] Object of type
dict[Unknown | str, Unknown | None]is not assignable todict[Literal["index", "columns"], Any] - Found 3388 diagnostics
- Found 3386 diagnostics
rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/bitcoin/xpub.py:217:25: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/chain/bitcoin/xpub.py:223:25: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/chain/evm/decoding/balancer/constants.py:27:1: error[invalid-assignment] Object of type
dict[Unknown | str, Unknown | int]is not assignable todict[str, Literal[1, 2, 3]] - rotkehlchen/db/dbhandler.py:1315:75: error[invalid-argument-type] Argument to function
insert_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/db/dbhandler.py:1370:13: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/db/dbhandler.py:1731:67: error[invalid-argument-type] Argument to function
insert_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/db/dbhandler.py:1765:68: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/db/dbhandler.py:3213:17: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/db/dbhandler.py:3222:17: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/rotkehlchen.py:939:17: error[invalid-argument-type] Argument to function
replace_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/tests/utils/xpubs.py:34:13: error[invalid-argument-type] Argument to function
insert_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - rotkehlchen/tests/utils/xpubs.py:52:13: error[invalid-argument-type] Argument to function
insert_tag_mappingsis incorrect: Expectedlist[Literal["identifier", "chain", "address", "xpub.xpub", "derivation_path"]], foundlist[Unknown | str] - Found 1714 diagnostics
- Found 1702 diagnostics
core (https://github.com/home-assistant/core)
- homeassistant/components/recorder/statistics.py:1913:9: error[invalid-argument-type] Argument to function
_statistics_at_timeis incorrect: Expectedset[Literal["last_reset", "max", "mean", "min", "state", "sum"]], foundset[Unknown | str] - homeassistant/components/sensor/recorder.py:584:34: error[invalid-argument-type] Argument to function
get_latest_short_term_statistics_with_sessionis incorrect: Expectedset[Literal["last_reset", "max", "mean", "min", "state", "sum"]], foundset[Unknown | str] - Found 13695 diagnostics
- Found 13693 diagnostics
materialize (https://github.com/MaterializeInc/materialize)
- ci/deploy/pypi.py:23:1: error[invalid-assignment] Object of type
dict[Unknown | str, Unknown | str]is not assignable todict[str, Literal["setup.py", "pyproject.toml"]] - Found 3388 diagnostics
- Found 3387 diagnostics
scipy (https://github.com/scipy/scipy)
- scipy/stats/_qmc.py:2609:26: error[invalid-argument-type] Method
__getitem__of typebound method dict[str, ((...) -> Unknown) | ((best_sample: ndarray[@Todo, Unknown], n_iters: int, n_nochange: int, rng: GeneratorType@_random_cd, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown]) | ((sample: @Todo, *, tol: @Todo = float, maxiter: @Todo = int, qhull_options: str | None = None, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown])].__getitem__(key: str, /) -> ((...) -> Unknown) | ((best_sample: ndarray[@Todo, Unknown], n_iters: int, n_nochange: int, rng: GeneratorType@_random_cd, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown]) | ((sample: @Todo, *, tol: @Todo = float, maxiter: @Todo = int, qhull_options: str | None = None, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown])cannot be called with key of typeLiteral["random-cd", "lloyd"] | Noneon object of typedict[str, ((...) -> Unknown) | ((best_sample: ndarray[@Todo, Unknown], n_iters: int, n_nochange: int, rng: GeneratorType@_random_cd, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown]) | ((sample: @Todo, *, tol: @Todo = float, maxiter: @Todo = int, qhull_options: str | None = None, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown])]
- scipy/stats/_qmc.py:2609:26: error[invalid-argument-type] Method
__getitem__of typebound method dict[str, ((...) -> Unknown) | ((best_sample: ndarray[@Todo, Unknown], n_iters: int, n_nochange: int, rng: GeneratorType@_random_cd, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown]) | ((sample: @Todo, *, tol: @Todo = float, maxiter: @Todo = Literal[10], qhull_options: str | None = None, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown])].__getitem__(key: str, /) -> ((...) -> Unknown) | ((best_sample: ndarray[@Todo, Unknown], n_iters: int, n_nochange: int, rng: GeneratorType@_random_cd, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown]) | ((sample: @Todo, *, tol: @Todo = float, maxiter: @Todo = Literal[10], qhull_options: str | None = None, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown])cannot be called with key of typeLiteral["random-cd", "lloyd"] | Noneon object of typedict[str, ((...) -> Unknown) | ((best_sample: ndarray[@Todo, Unknown], n_iters: int, n_nochange: int, rng: GeneratorType@_random_cd, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown]) | ((sample: @Todo, *, tol: @Todo = float, maxiter: @Todo = Literal[10], qhull_options: str | None = None, **kwargs: dict[Unknown, Unknown]) -> ndarray[@Todo, Unknown])]
No memory usage changes detected ✅