Skip to content

Assigning a dict literal to a list variable in a function raises no issue #12171

Closed
@trevor-e-apple

Description

@trevor-e-apple

Bug Report

(A clear and concise description of what the bug is.)

To Reproduce

The following code reproduces the issue

from typing import List

class Foo():
	def __init__(self):
		pass

def test_make_update_sql_multiple():
    where_args: List[Foo] = {"any": "thing"}
    print(where_args)

Expected Behavior

The following code produces the expected behavior (raise an error with assigning a dict to a List)

from typing import List

class Foo():
	def __init__(self):
		pass

where_args: List[Foo] = {"any": "thing"}
print(where_args)

Actual Behavior

Mypy sees no problem

Your Environment

  • Mypy version used: 0.931
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.5
  • Operating system and version: Windows 10.0.19044 Build 19044

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions