FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Get type information from isinstance assertions by ddfisher · Pull Request #1346 · python/mypy · GitHub

Repository navigation

Get type information from isinstance assertions - #1346

Merged
gvanrossum merged 2 commits into
python:masterfrom
ddfisher:master
Apr 8, 2016
Merged

gvanrossum merged 2 commits into
python:masterfrom
ddfisher:master

Conversation

ddfisher commented Apr 8, 2016

Copy link
Copy Markdown
Collaborator

Fixes #475.

Should probably be reviewed by someone who understands the checker's self.binder.

Copy link
Copy Markdown
Member

LGTM, you an merge it yourself once the tests pass. Yay!

Copy link
Copy Markdown
Member

Hold on, I don't know the binder that well.

--Guido (mobile)
On Apr 7, 2016 5:35 PM, "David Fisher" notifications@github.com wrote:

Fixes #475 #475.

Should probably be reviewed by someone who understands the checker's

self.binder.

You can view, comment on, or merge this pull request online at:

#1346
Commit Summary

  • Get type information from isinstance assertions

File Changes

Patch Links:

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1346

ddfisher commented Apr 8, 2016

Copy link
Copy Markdown
Collaborator Author

One caveat that I realized is that this will widen the type if you assert something very defensively. For example:

def f(x: int):
  assert isinstance(x, object)
  # x now has type object
  return x + 1  # error

I ran this against our current annotations and found one instance of something like this. (Worked fine otherwise, though!)

gvanrossum commented Apr 8, 2016 via email

Copy link
Copy Markdown
Member

ddfisher commented Apr 8, 2016

Copy link
Copy Markdown
Collaborator Author

Just checked -- it has the same behavior. (Which make sense, as I based this code on the if isinstance(...) code.)

gvanrossum merged commit 848f821 into python:master Apr 8, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL