MCPcopy Index your code
hub / github.com/python/mypy / get_cache_names

Function get_cache_names

mypy/build.py:1933–1971  ·  view source on GitHub ↗

Return the file names for the cache files. Args: id: module ID path: module path options: build options Returns: A tuple with the file names to be used for the meta file, the data file, and the fine-grained deps JSON, respectively.

(id: str, path: str, options: Options)

Source from the content-addressed store, hash-verified

1931
1932
1933def get_cache_names(id: str, path: str, options: Options) -> tuple[str, str, str | None]:
1934 """Return the file names for the cache files.
1935
1936 Args:
1937 id: module ID
1938 path: module path
1939 options: build options
1940
1941 Returns:
1942 A tuple with the file names to be used for the meta file, the
1943 data file, and the fine-grained deps JSON, respectively.
1944 """
1945 if options.cache_map:
1946 pair = options.cache_map.get(normpath(path, options))
1947 else:
1948 pair = None
1949 if pair is not None:
1950 # The cache map paths were specified relative to the base directory,
1951 # but the filesystem metastore APIs operates relative to the cache
1952 # prefix directory.
1953 # Solve this by rewriting the paths as relative to the root dir.
1954 # This only makes sense when using the filesystem backed cache.
1955 root = _cache_dir_prefix(options)
1956 return os.path.relpath(pair[0], root), os.path.relpath(pair[1], root), None
1957 prefix = os.path.join(*id.split("."))
1958 is_package = os.path.basename(path).startswith("__init__.py")
1959 if is_package:
1960 prefix = os_path_join(prefix, "__init__")
1961
1962 deps_json = None
1963 if options.cache_fine_grained:
1964 deps_json = prefix + ".deps.json"
1965 if options.fixed_format_cache:
1966 data_suffix = ".data.ff"
1967 meta_suffix = ".meta.ff"
1968 else:
1969 data_suffix = ".data.json"
1970 meta_suffix = ".meta.json"
1971 return prefix + meta_suffix, prefix + data_suffix, deps_json
1972
1973
1974def options_snapshot(id: str, manager: BuildManager) -> dict[str, object]:

Callers 9

report_config_dataMethod · 0.90
get_ir_cache_nameFunction · 0.90
write_cacheFunction · 0.90
write_deps_cacheFunction · 0.85
find_cache_metaFunction · 0.85
validate_metaFunction · 0.85
write_cacheFunction · 0.85
load_treeMethod · 0.85

Calls 7

os_path_joinFunction · 0.90
normpathFunction · 0.85
_cache_dir_prefixFunction · 0.85
splitMethod · 0.80
getMethod · 0.45
joinMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…