-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix inference logic for isinstance #2997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a29069e
8d7811a
14efa16
d9f261f
b110b11
fc1aa62
be30faa
f0bfcb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1360,3 +1360,11 @@ def f(x: object) -> None: | |
reveal_type(b) # E: Revealed type is '__main__.A' | ||
[builtins fixtures/isinstance.pyi] | ||
[out] | ||
|
||
[case testIsInstanceWithTypeVariable] | ||
from typing import * | ||
def f(x: Union[int, str], typ: type) -> None: | ||
if isinstance(x, (typ, int)): | ||
x + 1 # E: Unsupported operand types for + (likely involving Union) | ||
[builtins fixtures/isinstancelist.pyi] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not directly related, but can you add a test case that does something like |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test for the type object that is
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add also an
else:
block and do areveal_type(x)
in that block. Add anotherreveal_type(x)
just after the if statement.