mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[chore] clear all 64 pre-existing mypy errors in tests/ (no type:ignore)
Convention: no type:ignore/noqa, and pre-existing violations still violate. The make-quality gate runs 'mypy roboco/ tests/', but the prior commits' gates only ran mypy on production files, masking 64 type errors across 15 test files (method-assign, unused-ignore, no-untyped-def, attr-defined, union-attr, has-type, index, misc). Fixed without any type:ignore: - method-assign (svc.session.X = / svc.method = AsyncMock()): hold a local 'session: MagicMock'/'AsyncMock' and assert on it, or stub via object.__setattr__ / monkeypatch / a typed '_bind' helper returning Any, or alias 'cc: Any = c' (the pattern the file already used). - unused 'type: ignore[assignment]' (real code was method-assign): removed; replaced with the no-suppression patterns above. - 'Callable[...] has no attribute assert_*': keep a typed local ref to the AsyncMock and assert on the local, not the method-typed attr. - no-untyped-def: annotate helper params (Any / pytest.MonkeyPatch). - attr-defined / index / union-attr: type the helper as Any, narrow with an 'is not None' assert, or add the missing attr to a fake. - has-type / return-value: fix the declared return type to the tuple the function actually returns. - PLC0415 inline imports: hoisted to top-level. test_pr_gate_notifies_pm._stub_gate_path converted fully to the 'cc: Any = c' alias (it already used it for one attr) so its five '# type: ignore[method-assign]' suppressions are gone. mypy tests/: 64 errors -> 0 (538 files). ruff check tests/: clean. All 84 tests in the touched files pass.
This commit is contained in:
@@ -181,13 +181,13 @@ async def test_merge_already_merged_pr_is_idempotent_success(
|
||||
svc, "_get_project_token_or_raise", AsyncMock(return_value="tok")
|
||||
)
|
||||
monkeypatch.setattr(svc, "_parse_github_remote", lambda _ws: ("owner", "repo"))
|
||||
monkeypatch.setattr(
|
||||
svc, "_delete_pr_branch_best_effort", AsyncMock(return_value=None)
|
||||
)
|
||||
delete_branch = AsyncMock(return_value=None)
|
||||
monkeypatch.setattr(svc, "_delete_pr_branch_best_effort", delete_branch)
|
||||
monkeypatch.setattr(
|
||||
svc, "_project_default_branch", AsyncMock(return_value="master")
|
||||
)
|
||||
monkeypatch.setattr(svc, "_sync_target_branch", AsyncMock(return_value="abc123"))
|
||||
sync_target = AsyncMock(return_value="abc123")
|
||||
monkeypatch.setattr(svc, "_sync_target_branch", sync_target)
|
||||
# No fallback retry would help (already merged => 405 either way); make the
|
||||
# fallback lookup return None so the code falls straight through to the
|
||||
# already-merged disambiguation.
|
||||
@@ -208,8 +208,8 @@ async def test_merge_already_merged_pr_is_idempotent_success(
|
||||
assert commit == "abc123"
|
||||
# The post-merge steps still run (branch cleanup, target sync) so the
|
||||
# caller's state stays consistent with "the PR is merged".
|
||||
svc._delete_pr_branch_best_effort.assert_awaited_once()
|
||||
svc._sync_target_branch.assert_awaited_once()
|
||||
delete_branch.assert_awaited_once()
|
||||
sync_target.assert_awaited_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -224,9 +224,8 @@ async def test_merge_raises_when_not_merged_and_refused(
|
||||
svc, "_get_project_token_or_raise", AsyncMock(return_value="tok")
|
||||
)
|
||||
monkeypatch.setattr(svc, "_parse_github_remote", lambda _ws: ("owner", "repo"))
|
||||
monkeypatch.setattr(
|
||||
svc, "_delete_pr_branch_best_effort", AsyncMock(return_value=None)
|
||||
)
|
||||
delete_branch = AsyncMock(return_value=None)
|
||||
monkeypatch.setattr(svc, "_delete_pr_branch_best_effort", delete_branch)
|
||||
monkeypatch.setattr(
|
||||
svc, "_project_default_branch", AsyncMock(return_value="master")
|
||||
)
|
||||
@@ -244,4 +243,4 @@ async def test_merge_raises_when_not_merged_and_refused(
|
||||
await svc.merge_pull_request(Path("/tmp/ws"), 42, "squash", "proj")
|
||||
|
||||
# No post-merge cleanup ran — the merge did not land.
|
||||
svc._delete_pr_branch_best_effort.assert_not_awaited()
|
||||
delete_branch.assert_not_awaited()
|
||||
|
||||
Reference in New Issue
Block a user