All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gow <davidgow@google.com>
To: Daniel Latypov <dlatypov@google.com>
Cc: brendanhiggins@google.com, rmoar@google.com,
	linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com,
	linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org,
	johannes@sipsolutions.net,
	Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH v2 1/3] kunit: tool: add subscripts for type annotations where appropriate
Date: Fri, 17 Mar 2023 13:45:43 +0800	[thread overview]
Message-ID: <CABVgOS=1WQ1m7-fFuPNZBQ+CbfnDofKQ-xcknqnSDgUFEsR7EA@mail.gmail.com> (raw)
In-Reply-To: <20230316220638.983743-1-dlatypov@google.com>

[-- Attachment #1: Type: text/plain, Size: 4072 bytes --]

On Fri, 17 Mar 2023 at 06:06, Daniel Latypov <dlatypov@google.com> wrote:
>
> 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>
> ---
> Note: this is unchanged, just added a 3rd patch to this series.
> ---

Looks good.

Reviewed-by: David Gow <davidgow@google.com>

Thanks, Johannes and Daniel!

-- David

>  tools/testing/kunit/kunit_kernel.py  | 6 +++---
>  tools/testing/kunit/kunit_printer.py | 2 +-
>  tools/testing/kunit/run_checks.py    | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
> index 53e90c335834..e6fc8fcb071a 100644
> --- a/tools/testing/kunit/kunit_kernel.py
> +++ b/tools/testing/kunit/kunit_kernel.py
> @@ -92,7 +92,7 @@ class LinuxSourceTreeOperations:
>                 if stderr:  # likely only due to build warnings
>                         print(stderr.decode())
>
> -       def start(self, params: List[str], build_dir: str) -> subprocess.Popen:
> +       def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]:
>                 raise RuntimeError('not implemented!')
>
>
> @@ -112,7 +112,7 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations):
>                 kconfig.merge_in_entries(base_kunitconfig)
>                 return kconfig
>
> -       def start(self, params: List[str], build_dir: str) -> subprocess.Popen:
> +       def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]:
>                 kernel_path = os.path.join(build_dir, self._kernel_path)
>                 qemu_command = ['qemu-system-' + self._qemu_arch,
>                                 '-nodefaults',
> @@ -141,7 +141,7 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations):
>                 kconfig.merge_in_entries(base_kunitconfig)
>                 return kconfig
>
> -       def start(self, params: List[str], build_dir: str) -> subprocess.Popen:
> +       def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]:
>                 """Runs the Linux UML binary. Must be named 'linux'."""
>                 linux_bin = os.path.join(build_dir, 'linux')
>                 params.extend(['mem=1G', 'console=tty', 'kunit_shutdown=halt'])
> diff --git a/tools/testing/kunit/kunit_printer.py b/tools/testing/kunit/kunit_printer.py
> index 5f1cc55ecdf5..015adf87dc2c 100644
> --- a/tools/testing/kunit/kunit_printer.py
> +++ b/tools/testing/kunit/kunit_printer.py
> @@ -15,7 +15,7 @@ _RESET = '\033[0;0m'
>  class Printer:
>         """Wraps a file object, providing utilities for coloring output, etc."""
>
> -       def __init__(self, output: typing.IO):
> +       def __init__(self, output: typing.IO[str]):
>                 self._output = output
>                 self._use_color = output.isatty()
>
> diff --git a/tools/testing/kunit/run_checks.py b/tools/testing/kunit/run_checks.py
> index 066e6f938f6d..61cece1684df 100755
> --- a/tools/testing/kunit/run_checks.py
> +++ b/tools/testing/kunit/run_checks.py
> @@ -37,7 +37,7 @@ def main(argv: Sequence[str]) -> None:
>         if argv:
>                 raise RuntimeError('This script takes no arguments')
>
> -       future_to_name: Dict[futures.Future, str] = {}
> +       future_to_name: Dict[futures.Future[None], str] = {}
>         executor = futures.ThreadPoolExecutor(max_workers=len(commands))
>         for name, argv in commands.items():
>                 if name in necessary_deps and shutil.which(necessary_deps[name]) is None:
>
> base-commit: 2c6a96dad5797e57b4cf04101d6c8d5c7a571603
> --
> 2.40.0.rc1.284.g88254d51c5-goog
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

  parent reply	other threads:[~2023-03-17  5:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 22:06 [PATCH v2 1/3] kunit: tool: add subscripts for type annotations where appropriate Daniel Latypov
2023-03-16 22:06 ` [PATCH v2 2/3] kunit: tool: remove unused imports and variables Daniel Latypov
2023-03-17  5:47   ` David Gow
2023-03-16 22:06 ` [PATCH v2 3/3] kunit: tool: fix pre-existing `mypy --strict` errors and update run_checks.py Daniel Latypov
2023-03-17  5:50   ` David Gow
2023-03-17  5:45 ` David Gow [this message]
2023-04-30 18:15 ` [PATCH v2 1/3] kunit: tool: add subscripts for type annotations where appropriate SeongJae Park
2023-04-30 21:34   ` Daniel Latypov
2023-05-01 17:15     ` SeongJae Park
2023-05-01 18:19       ` Daniel Latypov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABVgOS=1WQ1m7-fFuPNZBQ+CbfnDofKQ-xcknqnSDgUFEsR7EA@mail.gmail.com' \
    --to=davidgow@google.com \
    --cc=brendanhiggins@google.com \
    --cc=dlatypov@google.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rmoar@google.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.