Repository: python/mypy

Issue:
fine-grained crashes when a package is turned into a regular module
Seen in the wild

```
[case turnPackageToModule1]
[file a.py]
import p
[file p/__init__.py]
[delete p/__init__.py.2]
[file p.py.2]
[out]
==
```
crashes with
```
/home/msullivan/src/mypy/mypy/test/testfinegrained.py:121: in run_case
    new_messages = self.run_check(server, sources)
/home/msullivan/src/mypy/mypy/test/testfinegrained.py:181: in run_check
    response = server.check(sources)
/home/msullivan/src/mypy/mypy/dmypy_server.py:241: in check
    res = self.fine_grained_increment(sources)
/home/msullivan/src/mypy/mypy/dmypy_server.py:302: in fine_grained_increment
    messages = self.fine_grained_manager.update(changed, removed)
/home/msullivan/src/mypy/mypy/server/update.py:231: in update
    result = self.update_one(changed_modules, initial_set, removed_set)
/home/msullivan/src/mypy/mypy/server/update.py:283: in update_one
    result = self.update_module(next_id, next_path, next_id in removed_set)
/home/msullivan/src/mypy/mypy/server/update.py:335: in update_module
    force_removed)
/home/msullivan/src/mypy/mypy/server/update.py:417: in update_module_isolated
    assert_equivalent_paths(path, manager.modules[module].path)
/home/msullivan/src/mypy/mypy/server/update.py:533: in assert_equivalent_paths
    assert path1 == path2, '%s != %s' % (path1, path2)
E   AssertionError: /tmp/mypy-test-wk6tir67/tmp/p.py != /tmp/mypy-test-wk6tir67/tmp/p/__init__.py
```


Discussion:
I think the right thing might be to just... remove the assert?

Resolving patch:
diff --git a/mypy/server/update.py b/mypy/server/update.py
--- a/mypy/server/update.py
+++ b/mypy/server/update.py
@@ -413,9 +413,7 @@ def update_module_isolated(module: str,
 
     Returns a named tuple describing the result (see above for details).
     """
-    if module in manager.modules:
-        assert_equivalent_paths(path, manager.modules[module].path)
-    else:
+    if module not in manager.modules:
         manager.log_fine_grained('new module %r' % module)
 
     if not manager.fscache.isfile(path) or force_removed:
@@ -527,12 +525,6 @@ def find_relative_leaf_module(modules: List[Tuple[str, str]], graph: Graph) -> T
     return modules[0]
 
 
-def assert_equivalent_paths(path1: str, path2: str) -> None:
-    path1 = os.path.normpath(os.path.abspath(path1))
-    path2 = os.path.normpath(os.path.abspath(path2))
-    assert path1 == path2, '%s != %s' % (path1, path2)
-
-
 def delete_module(module_id: str,
                   graph: Graph,
                   manager: BuildManager) -> None:


Test patch:
diff --git a/test-data/unit/fine-grained-modules.test b/test-data/unit/fine-grained-modules.test
--- a/test-data/unit/fine-grained-modules.test
+++ b/test-data/unit/fine-grained-modules.test
@@ -1746,3 +1746,39 @@ p/b.py: note: Ancestor package 'p' ignored
 p/b.py: note: (Using --follow-imports=error, submodule passed on command line)
 p/b.py:1: error: Cannot find module named 'z'
 p/b.py:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
+
+[case testTurnPackageToModule]
+[file a.py]
+[file b.py]
+import p
+x = p.f()
+[file p/__init__.py]
+def f() -> int: pass
+[delete p/__init__.py.2]
+[file p.py.2]
+def f() -> str: pass
+[file a.py.3]
+import b
+reveal_type(b.x)
+[out]
+==
+==
+a.py:2: error: Revealed type is 'builtins.str'
+
+[case testModuleToPackage]
+[file a.py]
+[file b.py]
+import p
+x = p.f()
+[file p.py]
+def f() -> str: pass
+[delete p.py.2]
+[file p/__init__.py.2]
+def f() -> int: pass
+[file a.py.3]
+import b
+reveal_type(b.x)
+[out]
+==
+==
+a.py:2: error: Revealed type is 'builtins.int'