def perform_mypy_check(repo_name: str) -> Set[str]: logger.info(f"Running mypy against {repo_name}") repo_opts = get_repo_configuration(repo_name) result = subprocess.run( [ "bash", "-c", f"cd ./{config.REPOS_PREFIX}/{repo_name} && " + " ".join(["mypy"] + ([repo_opts.additional_mypy_opts] if repo_opts. additional_mypy_opts else []) + [f"{file}" for file in repo_opts.starting_points]), ], capture_output=True, ) logger.debug(f"found errors: {result}") return set(elem for elem in result.stdout.decode().split("\n") if elem)
def test_pyproject_toml_valid_section(mocker): mocker.patch("app.config.toml.load", return_value={"tool": {"mypy-bot": {"additional_mypy_opts": "--mock-flag"}}}) assert get_repo_configuration("mock_repo") == RepoOpts(additional_mypy_opts="--mock-flag")
def test_pyproject_toml_bogus_values(mocker): mocker.patch("app.config.toml.load", return_value={"tool": {"mypy-bot": {"random": "value"}}}) assert get_repo_configuration("mock_repo") == RepoOpts()
def test_pyproject_toml_loaded_no_mypy_bot_section(mocker): mocker.patch("app.config.toml.load", return_value={"mock": "config"}) assert get_repo_configuration("mock_repo") == RepoOpts()
def test_pyproject_toml_not_found(): assert get_repo_configuration("mock_repo") == RepoOpts()