⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

The different type (str) of unpacked inner dictionary items from the type (int) of outer dictionary items gets error #20705

@hyperkai

Description

@hyperkai

*Memo:

  • mypy test.py
  • Python 3.14.0
  • mypy 1.19.1

The different type (str) of unpacked inner list items from the type (int) of outer list items doesn't get error as shown below:

v = [0, 1, *['a', 'b']] # No error

The different type (str) of unpacked inner dictionary items from the type (int) of outer dictionary items gets the error as shown below:

v = {0: 1, **{'a':'b'}} # Error

error: Cannot infer value of type parameter "KT" of

In additioin, if the types of keys in an inter and outer dictionary are the same, error doesn't occur as shown below:

v1 = {0: 1, **{2:'b'}}
v2 = {'0': 1, **{'a':'b'}}
# No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-contextType context / bidirectional inference

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions