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

Function take_module_snapshot

mypy/build.py:749–762  ·  view source on GitHub ↗

Take plugin module snapshot by recording its version and hash. We record _both_ hash and the version to detect more possible changes (e.g. if there is a change in modules imported by a plugin).

(module: types.ModuleType)

Source from the content-addressed store, hash-verified

747
748
749def take_module_snapshot(module: types.ModuleType) -> str:
750 """Take plugin module snapshot by recording its version and hash.
751
752 We record _both_ hash and the version to detect more possible changes
753 (e.g. if there is a change in modules imported by a plugin).
754 """
755 if hasattr(module, "__file__"):
756 assert module.__file__ is not None
757 with open(module.__file__, "rb") as f:
758 digest = hash_digest(f.read())
759 else:
760 digest = "unknown"
761 ver = getattr(module, "__version__", "none")
762 return f"{ver}:{digest}"
763
764
765def find_config_file_line_number(path: str, section: str, setting_name: str) -> int:

Callers 1

load_plugins_from_configFunction · 0.85

Calls 4

hash_digestFunction · 0.90
hasattrFunction · 0.85
getattrFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…