-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
- Are you reporting a bug, or opening a feature request?
Bug
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
TestOne = TypedDict('TestOne', {'test': int, 'another': str}, total=False)
TestTwo = TypedDict('TestTwo', {'test': int}, total=False)
var_1: TestOne = {'test': 1, 'another': 'hi'}
var_2: TestTwo = var_1 # Doesn't cause a type error... why not?? 'another' is not a valid key on a TestTwo
var_3: TestTwo = { # Does cause a type error, correctly. "Extra key 'another' for TypedDict 'TestTwo'"
'test': 2, 'another': 'hi'
}
TestThree = TypedDict('TestThree', {'test': int}, total=False)
TestFour = TypedDict('TestFour', {'test': int, 'another': str}, total=False)
var_4: TestThree = {'test': 3}
var_5: TestFour = var_4 # Causes a type error.... WHY???? "Incompatible types in assignment (expression has type "TestThree", variable has type "TestFour")"
- What is the actual behavior/output?
Basically, the code above, including its inline notes, but I'll summarize:
If you assign a value who's type is a TypedDict with some keys and total=False to be the value of a variable who's type is another TypedDict with total=False and a subset of the first TypedDict's keys, it throws an error, but it should not.
If you assign a value who's type is a TypedDict with some keys and total=False to be the value of a variable who's type is another TypedDict with total=False and a superset of the first TypedDict's keys, it does not throw an error, but it should.
- What are the versions of mypy and Python you are using?
Python version 3.6.4
Mypy version 0.670
- Do you see the same issue after installing mypy from Git master?
After installing mypy-0.680+dev.4e0a1583aeb00b248e187054980771f1897a1d31 from github, I get the same exact errors.
- What are the mypy flags you are using? (For example --strict-optional)
Here is my mypy.ini:
[mypy]
plugins = sqlmypy
disallow_untyped_calls = False
disallow_untyped_defs = True
ignore_missing_imports = True
warn_return_any = False
follow_imports = silent
allow_redefinition = True
-
If mypy crashed with a traceback, please paste
It did not.