Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better error message for nested TypedDict - #11658

Merged
97littleleaf11 merged 3 commits into
python:masterfrom
97littleleaf11:fix-4299
Dec 3, 2021
Merged

Better error message for nested TypedDict#11658
97littleleaf11 merged 3 commits into
python:masterfrom
97littleleaf11:fix-4299

Conversation

@97littleleaf11

Copy link
Copy Markdown
Collaborator

Description

Closes #4299

Test Plan

Add a new test case testCannotCreateTypedDictInstanceWithInlineTypedDict

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Left one idea about tweaking the error message (optional). Feel free to merge.

Comment thread mypy/semanal_typeddict.py Outdated
isinstance(field_type_expr.callee, RefExpr) and
field_type_expr.callee.fullname in TPDICT_NAMES):
self.fail_typeddict_arg(
'Inline TypedDict types not supported; use assignment',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bikeshedding: What about making this more detailed, such as like this:

Inline TypedDict types not supported; use assignment to define TypedDict

@97littleleaf11
97littleleaf11 merged commit 872bc86 into python:master Dec 3, 2021
@97littleleaf11
97littleleaf11 deleted the fix-4299 branch December 3, 2021 11:31
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better message for nested TypedDict

2 participants