MCPcopy
hub / github.com/python/mypy / options_snapshot

Function options_snapshot

mypy/build.py:1974–1990  ·  view source on GitHub ↗

Make compact snapshot of options for a module. Separately store only the options we may compare individually, and take a hash of everything else. If --debug-cache is specified, fall back to full snapshot.

(id: str, manager: BuildManager)

Source from the content-addressed store, hash-verified

1972
1973
1974def options_snapshot(id: str, manager: BuildManager) -> dict[str, object]:
1975 """Make compact snapshot of options for a module.
1976
1977 Separately store only the options we may compare individually, and take a hash
1978 of everything else. If --debug-cache is specified, fall back to full snapshot.
1979 """
1980 platform_opt, values = manager.options.clone_for_module(id).select_options_affecting_cache()
1981 if manager.options.debug_cache:
1982 # Build full options snapshot for debugging purposes.
1983 result: dict[str, object] = {"platform": platform_opt}
1984 for key, val in zip(OPTIONS_AFFECTING_CACHE_NO_PLATFORM, values):
1985 result[key] = val
1986 return result
1987 # Process most options quickly, since this is performance critical.
1988 buf = WriteBuffer()
1989 write_json_value(buf, cast(JsonValue, values))
1990 return {"platform": platform_opt, "other_options": hash_digest(buf.getvalue())}
1991
1992
1993def find_cache_meta(

Callers 3

find_cache_metaFunction · 0.85
validate_metaFunction · 0.85
write_cacheFunction · 0.85

Calls 5

write_json_valueFunction · 0.90
hash_digestFunction · 0.90
zipFunction · 0.85
clone_for_moduleMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…