Skip to content

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

Closed

Description

@Michael0x2a

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.

Activity

  1. 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[/+] on Jul 31, 2016
  2. gvanrossum commented on Aug 1, 2016

    @gvanrossum
    Member
  3. gnprice commented on Aug 4, 2016

    @gnprice
    Collaborator

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

  4. added this to the milestone on Aug 4, 2016
  5. self-assigned this
    on Aug 4, 2016
  6. gvanrossum commented on Oct 10, 2016

    @gvanrossum
    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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions