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

Skip to content

Fix narrowing of nested union of TypedDicts - #11204

Merged
JukkaL merged 1 commit into
python:masterfrom
bluetech:typeddict-union-narrowing
Oct 1, 2021
Merged

Fix narrowing of nested union of TypedDicts#11204
JukkaL merged 1 commit into
python:masterfrom
bluetech:typeddict-union-narrowing

Conversation

@bluetech

Copy link
Copy Markdown
Contributor

Description

Fixes #9308.

The code in refine_parent_types() bailed out when it encountered
something other than a TypedDict in the union, including a nested union
of TypedDicts. This caused the narrowing to fail.

Fix it by making it iterate over the flattened union items.

Test Plan

Added a unit test case. It fails before and passes after.

The code in refine_parent_types() bailed out when it encountered
something other than a TypedDict in the union, including a nested union
of TypedDicts. This caused the narrowing to fail.

Fix it by making it iterate over the flattened union items.

Fixes python#9308.

@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.

Looks good!

@JukkaL
JukkaL merged commit e80da8c into python:master Oct 1, 2021
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.

tagged union of unions

2 participants