You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there a description of the mypy type checking algorithms? #1994
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.
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.
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.
Activity
ddfisher commentedon 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 commentedon Aug 8, 2016
Actually, @JukkaL's PhD thesis probably discusses the type checking approach, but I'm not sure if it's widely available.
[-]No error raised when returning None[/-][+]Is there a description of the mypy type checking algorithms?[/+]rwbarton commentedon Aug 10, 2016
I retitled this issue to reflect the non-duplicate part.
JukkaL commentedon 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.