Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
trevor-e-apple opened this issue Feb 12, 2022 · 3 comments
Closed
Labels
bug mypy got something wrong

Comments

@trevor-e-apple
Copy link

trevor-e-apple commented Feb 12, 2022

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
@trevor-e-apple trevor-e-apple added the bug mypy got something wrong label Feb 12, 2022
@erictraut
Copy link

Has there been any thought of enabling "--check-untyped-defs" by default? Someone seems to trip on this at least once a week.

@JelleZijlstra
Copy link
Member

Yes, I agree the current behavior is not at all intuitive. #11201 lists it as a possible change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants