Skip to content

Daemon sometimes gives spurious errors #4208

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
gvanrossum opened this issue Nov 4, 2017 · 3 comments
Closed

Daemon sometimes gives spurious errors #4208

gvanrossum opened this issue Nov 4, 2017 · 3 comments
Labels

Comments

@gvanrossum
Copy link
Member

gvanrossum commented Nov 4, 2017

Repro:

$ git co 528b6f67738debd2376fcf24d77715ba12da64cc  # dmypy3
$ python3 misc/incremental_checker.py --limit 40 --seed dDWZNp2XFrtdXl9vWPH8 --sample 40 -r $PWD commit 5d86e142  --daemon 
Assuming mypy is located at /Users/guido/src/mypy
Temp repo will be cloned at /Users/guido/src/mypy/tmp_repo
Testing file/dir located at /Users/guido/src/mypy/tmp_repo/mypy
Using cache data located at /Users/guido/src/mypy/.incremental_checker_cache.json

Cloning repo /Users/guido/src/mypy to /Users/guido/src/mypy/tmp_repo
Fetching commits starting at 5d86e142
Sampled down to 40 commits using random seed dDWZNp2XFrtdXl9vWPH8
Skipping commit (already cached): 9d10fcdab: "Fix test failures caused by merging of #4059 (#4138)"
.
.
.
Skipping commit (already cached): 648680875: "Rename semantic analyzer classes to SemanticAnalyzerPass[123] (#4093)"

Starting daemon
Note: first commit is evaluated twice to warm up cache
Now testing commit 9d10fcdab: "Fix test failures caused by merging of #4059 (#4138)"
    Output matches expected result!
    Incremental: 19.056 sec
    Original:    16.825 sec
Now testing commit 9d10fcdab: "Fix test failures caused by merging of #4059 (#4138)"
    Output matches expected result!
    Incremental: 0.415 sec
    Original:    16.825 sec
Now testing commit a1ace484e: "Make stubgen return status 0 on --help (#4160)"
    Output does not match expected result!
    Expected output (16.020 sec):



    Actual output: (15.678 sec):

        tmp_repo/mypy/semanal.py:553: error: "None" has no attribute "line"
        tmp_repo/mypy/semanal.py:2405: error: No overload variant of "__setitem__" of "list" matches argument types [builtins.int, mypy.types.Type]
        tmp_repo/mypy/semanal.py:2641: error: No overload variant of "__setitem__" of "list" matches argument types [builtins.int, mypy.types.Type]
        tmp_repo/mypy/semanal.py:3446: error: No overload variant of "__setitem__" of "list" matches argument types [builtins.int*, mypy.types.Type]
        tmp_repo/mypy/checkexpr.py:252: error: No overload variant of "get" of "Mapping" matches argument types [mypy.nodes.Expression]
        tmp_repo/mypy/fixup.py:168: error: "None" has no attribute "bases"
        tmp_repo/mypy/stubgen.py:452: error: Item "Type" of "Optional[Type]" has no attribute "arg_types"
.
.
.

This particular set of error messages is particularly persistent, I've gone through a sequence of versions of the daemon logic and I still get this.

@gvanrossum
Copy link
Member Author

These errors are all related to the binder. I'm going to try and understand how/where it may hold on to stale expression nodes.

@gvanrossum
Copy link
Member Author

gvanrossum commented Nov 5, 2017

In pdb I traced code related to the first error message. In mypy/meet.py line 110 there's a test whether t.type in s.type.mro which should be true but ends up being false. Here t.type looks like

<TypeInfo mypy.types.Type>

and s.type.mro looks like

[<TypeInfo mypy.types.Overloaded>, <TypeInfo mypy.types.FunctionLike>, <TypeInfo mypy.types.Type>, <TypeInfo mypy.nodes.Context>, <TypeInfo builtins.object>]

so t.type should be at index 2 but isn't, because this is comparing by object pointers. so one of these TypeInfos comes from a different generation tree than the other.

@gvanrossum
Copy link
Member Author

New theory. The stale tree leaks into the current state via a lookup in the parent package. I have a unit test that demonstrates this. No fix yet.

gvanrossum pushed a commit to gvanrossum/mypy that referenced this issue Nov 7, 2017
gvanrossum added a commit that referenced this issue Nov 8, 2017
Fixes #4185.
Fixes #4198.
Fixes #4195.
Fixes #4208.

Also some improvements to mypy/incremental_checker.py and report more stats about in-memory cache.
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