Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kunit: tool: add subscripts for type annotations where appropriate

E.g. for subprocess.Popen, it can be opened in `text=True` mode where it
returns strings, or `text=False` where it returns bytes.
To differentiate, you can annotate types as `Popen[str]` or
`Popen[bytes]`.

This patch should add subscripts in all the places we were missing them.

Reported-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/linux-kselftest/20230315105055.9b2be0153625.I7a2cb99b95dff216c0feed4604255275e0b156a7@changeid/
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Daniel Latypov and committed by
Shuah Khan
695e2603 2c6a96da

+5 -5
+3 -3
tools/testing/kunit/kunit_kernel.py
··· 92 92 if stderr: # likely only due to build warnings 93 93 print(stderr.decode()) 94 94 95 - def start(self, params: List[str], build_dir: str) -> subprocess.Popen: 95 + def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]: 96 96 raise RuntimeError('not implemented!') 97 97 98 98 ··· 112 112 kconfig.merge_in_entries(base_kunitconfig) 113 113 return kconfig 114 114 115 - def start(self, params: List[str], build_dir: str) -> subprocess.Popen: 115 + def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]: 116 116 kernel_path = os.path.join(build_dir, self._kernel_path) 117 117 qemu_command = ['qemu-system-' + self._qemu_arch, 118 118 '-nodefaults', ··· 141 141 kconfig.merge_in_entries(base_kunitconfig) 142 142 return kconfig 143 143 144 - def start(self, params: List[str], build_dir: str) -> subprocess.Popen: 144 + def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]: 145 145 """Runs the Linux UML binary. Must be named 'linux'.""" 146 146 linux_bin = os.path.join(build_dir, 'linux') 147 147 params.extend(['mem=1G', 'console=tty', 'kunit_shutdown=halt'])
+1 -1
tools/testing/kunit/kunit_printer.py
··· 15 15 class Printer: 16 16 """Wraps a file object, providing utilities for coloring output, etc.""" 17 17 18 - def __init__(self, output: typing.IO): 18 + def __init__(self, output: typing.IO[str]): 19 19 self._output = output 20 20 self._use_color = output.isatty() 21 21
+1 -1
tools/testing/kunit/run_checks.py
··· 37 37 if argv: 38 38 raise RuntimeError('This script takes no arguments') 39 39 40 - future_to_name: Dict[futures.Future, str] = {} 40 + future_to_name: Dict[futures.Future[None], str] = {} 41 41 executor = futures.ThreadPoolExecutor(max_workers=len(commands)) 42 42 for name, argv in commands.items(): 43 43 if name in necessary_deps and shutil.which(necessary_deps[name]) is None: