Skip to content

Is there a description of the mypy type checking algorithms? #1994

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
nguyenthanhvuh opened this issue Aug 7, 2016 · 4 comments
Closed

Is there a description of the mypy type checking algorithms? #1994

nguyenthanhvuh opened this issue Aug 7, 2016 · 4 comments

Comments

@nguyenthanhvuh
Copy link

nguyenthanhvuh commented Aug 7, 2016

Hi, I am just trying out mypy and have the following code in a file t.py:

def f1(x:int) -> int:                                                                           
    if x > 0:
        return 1

Running mypy t.py --strict-optional gives no error or warning. Am I missing something ?

Also, are there some technical documentations for mypy, e.g., what type inference and checking algorithms were used ? I saw some code about solving constraints in mypy, but I am more interested in a technical document.

Thanks,

@ddfisher
Copy link
Collaborator

ddfisher commented Aug 8, 2016

You're not missing anything -- we just don't detect falling off the end of a function yet. (See #1869 for the issue and #1748 for a complicated work in progress PR).

I don't think we have a technical document describing our type checking/inference algorithms, though we'd like to have something like that in the future. FYI, the constraint solving code is used for type variables, but not for the rest of type checking.

@ddfisher
Copy link
Collaborator

ddfisher commented Aug 8, 2016

Actually, @JukkaL's PhD thesis probably discusses the type checking approach, but I'm not sure if it's widely available.

@ddfisher ddfisher added this to the Questions milestone Aug 8, 2016
@rwbarton rwbarton changed the title No error raised when returning None Is there a description of the mypy type checking algorithms? Aug 10, 2016
@rwbarton
Copy link
Contributor

I retitled this issue to reflect the non-duplicate part.

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 11, 2016

The PhD thesis is from 2013 and a lot has changed since then. One of the main ideas in the PhD thesis is about having multiple runtime semantics and improving performance, and this has been completely dropped from mypy. Today the thesis is probably more confusing than useful if you want to understand mypy.

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

No branches or pull requests

5 participants