Skip to content

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

Closed

Description

@nguyenthanhvuh

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,

Activity

  1. ddfisher commented on Aug 8, 2016

    @ddfisher
    Collaborator

    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.

  2. ddfisher commented on Aug 8, 2016

    @ddfisher
    Collaborator

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

  3. added this to the milestone on Aug 8, 2016
  4. changed the title [-]No error raised when returning None[/-] [+]Is there a description of the mypy type checking algorithms?[/+] on Aug 10, 2016
  5. rwbarton commented on Aug 10, 2016

    @rwbarton
    Contributor

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

  6. JukkaL commented on Aug 11, 2016

    @JukkaL
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions