Repository navigation
Get type information from isinstance assertions - #1346
Conversation
|
LGTM, you an merge it yourself once the tests pass. Yay! |
|
Hold on, I don't know the binder that well. --Guido (mobile)
|
|
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 # errorI ran this against our current annotations and found one instance of something like this. (Worked fine otherwise, though!) |
|
And what does the equivalent code using `if isinstance(x, object)` do?
|
|
Just checked -- it has the same behavior. (Which make sense, as I based this code on the |
Fixes #475.
Should probably be reviewed by someone who understands the checker's
self.binder.