Skip to content

Fix binding of self-types on unions - #7152

Merged
ilevkivskyi merged 2 commits into
python:masterfrom
ilevkivskyi:fix-typeddict-plugin
Jul 5, 2019
Merged

ilevkivskyi merged 2 commits into
python:masterfrom
ilevkivskyi:fix-typeddict-plugin

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Fixes #7149

The fix is quite straightforward, self-types should be bound to each individual component, so I just added only basic tests. Please let me know if you want better test coverage (properties, class-methods) etc.

@ilevkivskyi
ilevkivskyi requested a review from JukkaL July 4, 2019 17:22

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

I like how this is a clean fix, and fixes a more general issue than what I reported. Just one comment about tests.

def same(self: T) -> T: ...

x: Union[A, C]
reveal_type(x.same) # N: Revealed type is 'Union[builtins.int, def () -> __main__.C*]'

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.

Maybe add a test for class method with a self type?

@ilevkivskyi
ilevkivskyi merged commit dab5b29 into python:master Jul 5, 2019
@ilevkivskyi
ilevkivskyi deleted the fix-typeddict-plugin branch July 5, 2019 13:22
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.

Crash when using Optional[TypedDictType]

2 participants