code: def chdir(path: str) -> Iterator[None]:
      
      curdir = os.getcwd()
      os.chdir(path)
      try:
          yield
      finally:
          os.chdir(curdir)
docs: Context manager for changing dir and restoring previous workdir after exit.