Skip to content

Commit 39f78a3

Browse files
authored
typing: clarify the type of bug_ids as Iterable (Bug 1759890) (#301)
The type of `bug_ids` is `list` but in reality any `Iterable` will work.
1 parent e14ff61 commit 39f78a3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

landoapi/commit_message.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66

77
from typing import (
8+
Iterable,
89
Optional,
910
)
1011

@@ -202,7 +203,7 @@ def split_title_and_summary(msg: str) -> tuple[str, str]:
202203
return title, summary
203204

204205

205-
def bug_list_to_commit_string(bug_ids: list[str]) -> str:
206+
def bug_list_to_commit_string(bug_ids: Iterable[str]) -> str:
206207
"""Convert a list of `str` bug IDs to a string for a commit message."""
207208
if not bug_ids:
208209
return "No bug"

landoapi/hg.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313

1414
from contextlib import contextmanager
1515
from pathlib import Path
16-
from typing import Optional
16+
from typing import (
17+
Iterable,
18+
Optional,
19+
)
1720

1821
import hglib
1922

@@ -464,7 +467,7 @@ def format_stack_amend(self) -> Optional[list[str]]:
464467

465468
raise exc
466469

467-
def format_stack_tip(self, bug_ids: list[str]) -> Optional[list[str]]:
470+
def format_stack_tip(self, bug_ids: Iterable[str]) -> Optional[list[str]]:
468471
"""Add an autoformat commit to the top of the patch stack.
469472
470473
Return the commit hash of the autoformat commit as a `str`,
@@ -492,7 +495,9 @@ def format_stack_tip(self, bug_ids: list[str]) -> Optional[list[str]]:
492495

493496
raise exc
494497

495-
def format_stack(self, stack_size: int, bug_ids: list[str]) -> Optional[list[str]]:
498+
def format_stack(
499+
self, stack_size: int, bug_ids: Iterable[str]
500+
) -> Optional[list[str]]:
496501
"""Format the patch stack for landing.
497502
498503
Return a list of `str` commit hashes where autoformatting was applied,

0 commit comments

Comments
 (0)