Write cache files for a module. Note that this mypy's behavior is still correct when any given write_cache() call is replaced with a no-op, so error handling code that bails without writing anything is okay. Args: id: module ID path: module path tree: the fully ch
(
id: str,
path: str,
tree: MypyFile,
dependencies: list[str],
suppressed: list[str],
suppressed_deps_opts: bytes,
imports_ignored: dict[int, list[str]],
dep_prios: list[int],
dep_lines: list[int],
old_interface_hash: bytes,
trans_dep_hash: bytes,
source_hash: str,
ignore_all: bool,
manager: BuildManager,
)
| 2267 | |
| 2268 | |
| 2269 | def write_cache( |
| 2270 | id: str, |
| 2271 | path: str, |
| 2272 | tree: MypyFile, |
| 2273 | dependencies: list[str], |
| 2274 | suppressed: list[str], |
| 2275 | suppressed_deps_opts: bytes, |
| 2276 | imports_ignored: dict[int, list[str]], |
| 2277 | dep_prios: list[int], |
| 2278 | dep_lines: list[int], |
| 2279 | old_interface_hash: bytes, |
| 2280 | trans_dep_hash: bytes, |
| 2281 | source_hash: str, |
| 2282 | ignore_all: bool, |
| 2283 | manager: BuildManager, |
| 2284 | ) -> tuple[bytes, tuple[CacheMeta, str] | None]: |
| 2285 | """Write cache files for a module. |
| 2286 | |
| 2287 | Note that this mypy's behavior is still correct when any given |
| 2288 | write_cache() call is replaced with a no-op, so error handling |
| 2289 | code that bails without writing anything is okay. |
| 2290 | |
| 2291 | Args: |
| 2292 | id: module ID |
| 2293 | path: module path |
| 2294 | tree: the fully checked module data |
| 2295 | dependencies: module IDs on which this module depends |
| 2296 | suppressed: module IDs which were suppressed as dependencies |
| 2297 | dep_prios: priorities (parallel array to dependencies) |
| 2298 | dep_lines: import line locations (parallel array to dependencies) |
| 2299 | old_interface_hash: the hash from the previous version of the data cache file |
| 2300 | source_hash: the hash of the source code |
| 2301 | ignore_all: the ignore_all flag for this module |
| 2302 | manager: the build manager (for pyversion, log/trace) |
| 2303 | |
| 2304 | Returns: |
| 2305 | A tuple containing the interface hash and inner tuple with CacheMeta |
| 2306 | that should be written and path to cache file (inner tuple may be None, |
| 2307 | if the cache data could not be written). |
| 2308 | """ |
| 2309 | metastore = manager.metastore |
| 2310 | # For Bazel we use relative paths and zero mtimes. |
| 2311 | bazel = manager.options.bazel |
| 2312 | |
| 2313 | # Obtain file paths. |
| 2314 | meta_file, data_file, _ = get_cache_names(id, path, manager.options) |
| 2315 | manager.log(f"Writing {id} {path} {meta_file} {data_file}") |
| 2316 | |
| 2317 | # Update tree.path so that in bazel mode it's made relative (since |
| 2318 | # sometimes paths leak out). |
| 2319 | if bazel: |
| 2320 | tree.path = path |
| 2321 | |
| 2322 | plugin_data = manager.plugin.report_config_data(ReportConfigContext(id, path, is_check=False)) |
| 2323 | |
| 2324 | # Serialize data and analyze interface |
| 2325 | if manager.options.fixed_format_cache: |
| 2326 | data_io = WriteBuffer() |
no test coverage detected
searching dependent graphs…