8000 Support TypedDicts with missing keys (total=False) by JukkaL · Pull Request #3558 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Support TypedDicts with missing keys (total=False) #3558

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

Merged
merged 20 commits into from
Jun 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Attempt to fix Python 3.3
  • Loading branch information
JukkaL committed Jun 16, 2017
commit 6223d2a06a6a74b03d38b24d11d696b65c81a782
2 changes: 1 addition & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def check_typeddict_call_with_dict(self, callee: TypedDictType,
def check_typeddict_call_with_kwargs(self, callee: TypedDictType,
kwargs: 'OrderedDict[str, Expression]',
context: Context) -> Type:
if not (callee.required_keys <= kwargs.keys() <= callee.items.keys()):
if not (callee.required_keys <= set(kwargs.keys()) <= set(callee.items.keys())):
callee_item_names = [key for key in callee.items.keys()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming these two variables expected_xxx and actual_xxx (matching the error message call below) would help in understanding what they mean.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good idea -- done.

if key in callee.required_keys or key in kwargs.keys()]
kwargs_item_names = kwargs.keys()
Expand Down
0