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)
| 747 | |
| 748 | |
| 749 | def 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 | |
| 765 | def find_config_file_line_number(path: str, section: str, setting_name: str) -> int: |
no test coverage detected
searching dependent graphs…