Skip to content

Commit 2e1acdf

Browse files
committed
framework: improve annotations
For the match functions that can take a list argument, annotate then as string-or-list-of-strings. (from review comment) Also the write method - the "filename" can be a list of strings (path components), annotate is as such as well. Signed-off-by: Mats Wichmann <mats@linux.com>
1 parent 9e935fe commit 2e1acdf

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

testing/framework/TestCmd.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ def pass_test(self=None, condition: bool = True, function=None) -> None:
552552

553553

554554
def match_exact(
555-
lines: str | list | None = None,
556-
matches: str | list | None = None,
555+
lines: str | list[str] | None = None,
556+
matches: str | list[str] | None = None,
557557
newline: str = os.sep,
558558
) -> int | None:
559559
"""Match function using exact match.
@@ -582,7 +582,8 @@ def match_exact(
582582

583583

584584
def match_caseinsensitive(
585-
lines: str | list | None = None, matches: str | list | None = None
585+
lines: str | list[str] | None = None,
586+
matches: str | list[str] | None = None,
586587
) -> int | None:
587588
"""Match function using case-insensitive matching.
588589
@@ -609,7 +610,10 @@ def match_caseinsensitive(
609610
return 1
610611

611612

612-
def match_re(lines: str | list | None = None, res: str | list | None = None) -> int | None:
613+
def match_re(
614+
lines: str | list[str] | None = None,
615+
res: str | list[str] | None = None,
616+
) -> int | None:
613617
"""Match function using line-by-line regular expression match.
614618
615619
Args:
@@ -642,7 +646,8 @@ def match_re(lines: str | list | None = None, res: str | list | None = None) ->
642646

643647

644648
def match_re_dotall(
645-
lines: str | list | None = None, res: str | list | None = None
649+
lines: str | list[str] | None = None,
650+
res: str | list[str] | None = None,
646651
) -> Match[str] | None:
647652
"""Match function using regular expression match.
648653
@@ -2160,7 +2165,7 @@ def do_chmod(fname) -> None:
21602165
do_chmod(os.path.join(dirpath, name))
21612166
do_chmod(top)
21622167

2163-
def write(self, file: str | list, content: str | bytes, mode: str = 'wb'):
2168+
def write(self, file: str | list[str], content: str | bytes, mode: str = 'wb'):
21642169
"""Writes data to file.
21652170
21662171
The file is created under the temporary working directory.

0 commit comments

Comments
 (0)