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

Function set_expected

misc/incremental_checker.py:211–241  ·  view source on GitHub ↗

Populates the given `cache` with the expected results for all of the given `commits`. This function runs mypy on the `target_file_path` inside the `temp_repo_path`, and stores the result in the `cache`. If `cache` already contains results for a particular commit, this function will

(
    commits: list[tuple[str, str]],
    cache: JsonDict,
    temp_repo_path: str,
    target_file_path: str | None,
    mypy_cache_path: str,
    mypy_script: str | None,
)

Source from the content-addressed store, hash-verified

209
210
211def set_expected(
212 commits: list[tuple[str, str]],
213 cache: JsonDict,
214 temp_repo_path: str,
215 target_file_path: str | None,
216 mypy_cache_path: str,
217 mypy_script: str | None,
218) -> None:
219 """Populates the given `cache` with the expected results for all of the given `commits`.
220
221 This function runs mypy on the `target_file_path` inside the `temp_repo_path`, and stores
222 the result in the `cache`.
223
224 If `cache` already contains results for a particular commit, this function will
225 skip evaluating that commit and move on to the next."""
226 for commit_id, message in commits:
227 if commit_id in cache:
228 print(f'Skipping commit (already cached): {commit_id}: "{message}"')
229 else:
230 print(f'Caching expected output for commit {commit_id}: "{message}"')
231 execute(["git", "-C", temp_repo_path, "checkout", commit_id])
232 runtime, output, stats = run_mypy(
233 target_file_path, mypy_cache_path, mypy_script, incremental=False
234 )
235 cache[commit_id] = {"runtime": runtime, "output": output}
236 if output == "":
237 print(f" Clean output ({runtime:.3f} sec)")
238 else:
239 print(f" Output ({runtime:.3f} sec)")
240 print_offset(output, 8)
241 print()
242
243
244def test_incremental(

Callers 1

test_repoFunction · 0.85

Calls 4

printFunction · 0.85
executeFunction · 0.70
run_mypyFunction · 0.70
print_offsetFunction · 0.70

Tested by 1

test_repoFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…