def _single_dir_pyright()

in eng/scripts/run_pyright.py [0:0]


def _single_dir_pyright(mod):
    inner_class = next(d for d in mod.iterdir() if d.is_dir() and not str(d).endswith("egg-info"))
    retries = 3
    while retries:
        try:
            check_output(
                [
                    sys.executable,
                    "-m",
                    "pyright",
                    "-p",
                    get_pyright_config_file_location(),
                    str(inner_class.absolute()),
                ],
                text=True,
            )
            return True
        except CalledProcessError as e:
            logging.exception("{} exited with pyright error {}".format(inner_class.stem, e.returncode))
            logging.error(f"PyRight stdout:\n{e.stdout}\n===========")
            logging.error(f"PyRight stderr:\n{e.stderr}\n===========")
            # PyRight has shown to randomly failed with a 217, retry the same folder 3 times should help
            retries -= 1
            time.sleep(5)

    return False