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

Function local_sys_path_set

mypy/test/helpers.py:299–311  ·  view source on GitHub ↗

Temporary insert current directory into sys.path. This can be used by test cases that do runtime imports, for example by the stubgen tests.

()

Source from the content-addressed store, hash-verified

297
298@contextlib.contextmanager
299def local_sys_path_set() -> Iterator[None]:
300 """Temporary insert current directory into sys.path.
301
302 This can be used by test cases that do runtime imports, for example
303 by the stubgen tests.
304 """
305 old_sys_path = sys.path.copy()
306 if not ("" in sys.path or "." in sys.path):
307 sys.path.insert(0, "")
308 try:
309 yield
310 finally:
311 sys.path = old_sys_path
312
313
314def testfile_pyversion(path: str) -> tuple[int, int]:

Callers 2

runMethod · 0.90
run_caseMethod · 0.90

Calls 2

insertMethod · 0.80
copyMethod · 0.45

Tested by 2

runMethod · 0.72
run_caseMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…