Skip to content

Fix narrowing from object to Optional - #4118

Merged
JukkaL merged 2 commits into
python:masterfrom
ilevkivskyi:fix-none-meet-object
Oct 26, 2017
Merged

JukkaL merged 2 commits into
python:masterfrom
ilevkivskyi:fix-none-meet-object

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Currently:

x: object
y: Optional[int]
x = y
reveal_type(x) # builtins.int

this is unexpected and may be unsafe. This PR fixes this by considering object as overlapping with everything (including None).

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

LGTM. Thanks for the fix!

@JukkaL
JukkaL merged commit 23b71df into python:master Oct 26, 2017
JukkaL pushed a commit that referenced this pull request Oct 31, 2017
Previously:

```
x: object
y: Optional[int]
x = y
reveal_type(x) # builtins.int
```

This was unexpected and may be unsafe. Fix this by considering object 
as overlapping with everything (including None).
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.

2 participants