Skip to content

Bug involving Python 2, incremental mode, partial cache invalidation, and possibly nested folders #1967

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
Michael0x2a opened this issue Jul 31, 2016 · 3 comments
Assignees
Labels

Comments

@Michael0x2a
Copy link
Collaborator

Michael0x2a commented Jul 31, 2016

I recently ran into a bug that manifests when running Python 2 with incremental mode. Here is the shortest repro I was able to create so far:

File structure

parent/
    __init__.py
    a.py
    b.py
    subfolder/
        __init__.py
        child_a/
            __init__.py
            c.py
        child_b/
            __init__.py
            d.py
e.py

parent/a.py

import e 
a_const = 0

parent/b.py

b_const = 0

parent/subfolder/child_a/__init__.py

from .c import c_const

parent/subfolder/child_a/c.py

from parent.b import b_const
c_const = 0

parent/subfolder/child_b/d.py

from parent.a import a_const
from ..child_a import c

e.py

from types import FunctionType

All of the other __init__.py files are empty.

When you try running mypy in incremental mode with Python 2, you get a spurious error in the second run (note that I update the timestamp of parent/b.py to force mypy to recheck that file):

$ rm -rf .mypy_cache
$ python3 -m mypy --py2 --incremental parent
$ touch parent/b.py
$ python3 -m mypy --py2 --incremental parent
experiments/parent/subfolder/child_b/d.py:2: error: Module has no attribute 'c'

However, mypy works as expected when running in Python 3 mode. I'm not entirely sure why that is.

I'm planning on continuing to try and make a shorter/more enlightening repro, but I figured I should file an issue now to get this on the record.

@Michael0x2a Michael0x2a changed the title Bug involving Python 2, incremental mode, and possibly nested folders Bug involving Python 2, incremental mode, partial cache invalidation, and possibly nested folders Jul 31, 2016
@gvanrossum
Copy link
Member

gvanrossum commented Aug 1, 2016 via email

@gnprice gnprice added the bug mypy got something wrong label Aug 4, 2016
@gnprice
Copy link
Collaborator

gnprice commented Aug 4, 2016

Apparently this triggers frequently when using --incremental on some of our larger internal codebases at Dropbox.

@gnprice gnprice added this to the 0.4.x milestone Aug 4, 2016
@Michael0x2a Michael0x2a self-assigned this Aug 4, 2016
@gvanrossum
Copy link
Member

I cannot repro this any more. According to git bisect it was fixed on August 18 by revision 95a0186, "Make incremental not propagate staleness if the public interface of a module is unchanged (v2) (#2014)". That's good enough for me!

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

4 participants