Skip to content

Basic isinstance() type inference #245

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

Closed
JukkaL opened this issue Jul 16, 2013 · 0 comments
Closed

Basic isinstance() type inference #245

JukkaL opened this issue Jul 16, 2013 · 0 comments
Assignees
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 16, 2013

The type checker should know about isinstance checks. For example, this code should be valid:

def f(x: object) -> None:
    if isinstance(x, str):
        # x has type str here.
        print(x + 'foo')  # ok

Initially only support cases where the first argument is a variable and the 'if' condition only contains an isinstance check. Later, consider extending this to more complex cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant