Skip to content

Commit efbb522

Browse files
author
hauntsaninja
committed
actually inherit from FileSystemCache to appease mypyc
This means we could accidentally fallback to calling a FileSystemCache method if stuff gets moved around.
1 parent dec730a commit efbb522

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

mypy/fscache.py

+2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
import stat
3333
from typing import Dict, List, Set
3434
from mypy.util import hash_digest
35+
from mypy_extensions import mypyc_attr
3536

3637

38+
@mypyc_attr(allow_interpreted_subclasses=True) # for tests
3739
class FileSystemCache:
3840
def __init__(self) -> None:
3941
# The package root is not flushed with the caches.

mypy/modulefinder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def compute_search_paths(sources: List[BuildSource],
578578
if not alt_lib_path:
579579
for source in sources:
580580
# Include directory of the program file in the module search path.
581-
if source.base_dir:
581+
if source.module.isidentifier() and source.base_dir:
582582
dir = source.base_dir
583583
if dir not in python_path:
584584
python_path.append(dir)

mypy/test/test_find_sources.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from mypy.modulefinder import BuildSource
22
import os
3-
from typing import Any, List, Optional, Set, Tuple, cast
3+
from typing import List, Optional, Set, Tuple
44
from unittest import TestCase
55
from mypy.find_sources import SourceFinder
6+
from mypy.fscache import FileSystemCache
67
from mypy.modulefinder import BuildSource
78
from mypy.options import Options
89

910

10-
class _FakeFSCache:
11+
class FakeFSCache(FileSystemCache):
1112
def __init__(self, files: Set[str]) -> None:
1213
assert all(os.path.isabs(f) for f in files)
1314
self.files = files
@@ -29,9 +30,6 @@ def init_under_package_root(self, file: str) -> bool:
2930
return False
3031

3132

32-
FakeFSCache = cast(Any, _FakeFSCache)
33-
34-
3533
def normalise_build_source_list(sources: List[BuildSource]) -> List[Tuple[str, Optional[str]]]:
3634
return sorted((s.module, s.base_dir) for s in sources)
3735

0 commit comments

Comments
 (0)