Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5766207rwr; Mon, 1 May 2023 10:23:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BRoTbZklsYdVkGXKyqAGZrNJqyJghQDKuqRriSBiwljFWaPgG9oPlNlIzJ8IBnWKcG6Q3 X-Received: by 2002:a05:6a20:728f:b0:f2:5b9f:fe73 with SMTP id o15-20020a056a20728f00b000f25b9ffe73mr21528132pzk.28.1682961818902; Mon, 01 May 2023 10:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682961818; cv=none; d=google.com; s=arc-20160816; b=02FBt5FuOtn71KNlUt8v+qL+NKEV3nTDk4n2VSofsX9kpia9Nf6P3LlamhdHYmltlR E58T0DQqg4hae3YwmoGGRUXvXm70NFvkGMo5/kg5cqANxgEOGyMjPae2L31uswfomMDF CJbzRKPqH/kLhv8E8sG1LnxzveusbRwO9gwyoH9UNbavfAXCWk9t16FmEEKgna9K7jUC HZ2e6dvrAjaicRhOS6bf8A43PtSuqgpwAJi6bKLg58aKrAIu3LbLwk2lpDsTb934BEo3 HkXHyJ+BBv52noQ4yxs2LHMMZJ67bQGkxfGezkPhf0QLLMsn30lxsr6u41nG5Pzm8ery B6yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sEdd+AsIiExuTdjYyBCc1l1qNoYN3T1HQt5qHJ9CHBE=; b=n7K+qjsbgN+rcB9YhKUJykqCou4jH3McJsxIZE6xvykB0ls9GhA9y0o99Go50RsD2r 64DLAFqt4eZPqrzNnaMVLkYWFhWtiNWIm3rZVPH15qFaXNTxVxcQKr0AOOZ0+IYuC+V/ 9q5K2VeqfTZPrfPH+2Sz9jOvzxJ5Mijwl6M5ulQO+TagSFzac/3n9XG8HqB0XL1YENst jWa9QgFbgJrmK3tCK8PB0KoDa2SOQpMNmfnC6IoWiEW7C41OTM3Fx4xJ4BZWXJT1MOQN VsTHN7gTzjX6ENd/IceqZai8hxwzlBvt16oxu58tz+k51ObemAUEml0LQh+POD0oiflQ hHPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qt/nwiWl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a6540cb000000b00513234112acsi27919609pgp.888.2023.05.01.10.23.25; Mon, 01 May 2023 10:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qt/nwiWl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbjEARQv (ORCPT + 99 others); Mon, 1 May 2023 13:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232869AbjEARPZ (ORCPT ); Mon, 1 May 2023 13:15:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9777DB; Mon, 1 May 2023 10:15:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 601A9611C5; Mon, 1 May 2023 17:15:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD6C8C433D2; Mon, 1 May 2023 17:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682961322; bh=Rnwd3jASwht07ENoOLmN+yQOD6wS2aI12lvNs7J1KiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qt/nwiWlP5Xj3LoPebLaYBd4begRxAvkF+fafNlLBq/yn0x2FClZiwL8v6Vrhy3mm fbarybHIQtkp6pNjeyiw6SwOmWnMhu49MSEq9eEyXR0MvmMQQbwoi4JGwOyrTf4ql6 BOtbWGVKN18JEydmlmUSpldN5kzQ2XvhoigQh1SzfusmHUJBoK2Kqd4sikw1JEWB3i A3rZpA0afXkH+OxsX9GQ/nEiH2G0tgf4aAGuZC4kFTapgY8dnx5vpuJRM9nsz0ozBQ FsnuoTtiejqSqmLJkYWWnfTFLvyMhc6kCWadRQuPZeI6BWjGZFk15FxEUD8CElE56Z G1CRz+jl1eeEw== From: SeongJae Park To: Daniel Latypov Cc: SeongJae Park , brendanhiggins@google.com, davidgow@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 , regressions@lists.linux.dev Subject: Re: [PATCH v2 1/3] kunit: tool: add subscripts for type annotations where appropriate Date: Mon, 1 May 2023 17:15:20 +0000 Message-Id: <20230501171520.138753-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On Sun, 30 Apr 2023 14:34:09 -0700 Daniel Latypov wrote: > On Sun, Apr 30, 2023 at 11:15 AM SeongJae Park wrote: > > > > Hi Daniel, > > > > On Thu, 16 Mar 2023 15:06:36 -0700 Daniel Latypov 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. > > > > I just found this patch is in the latest mainline tree, and it causes kunit > > failure on my test machine like below. > > > > $ python3 --version > > Python 3.8.10 > > $ > > $ ./tools/testing/kunit/kunit.py run --build_dir ../kunit.out/ > > Traceback (most recent call last): > > File "./tools/testing/kunit/kunit.py", line 24, in > > import kunit_kernel > > File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 42, in > > class LinuxSourceTreeOperations: > > File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 95, in LinuxSourceTreeOperations > > def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]: > > TypeError: 'type' object is not subscriptable > > $ > > > > I further confirmed reverting this patch makes it run again. Do you have any > > idea? > > It seems like support for the subscript wasn't added until Python 3.9. > > I know support for subscripting other types like re.Pattern was added > in 3.9 per https://peps.python.org/pep-0585/ but it doesn't mention > Popen there... > This patch also added typing.IO[str] and concurrent.Future[None], so > those might be problematic too. > > Can you check if the typing.IO and concurrent.Future[None] changes > cause problems? > (I don't have an easy way of testing against older Python versions currently). Thank you for quick reply. Reverting Popen changes only as below fixed my issue. So seems typing.IO and concurrent.Future[None] chages doesn't cause problems at least for my use case. diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index f01f94106129..7f648802caf6 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[str]: + def start(self, params: List[str], build_dir: str) -> subprocess.Popen: raise RuntimeError('not implemented!') @@ -113,7 +113,7 @@ class LinuxSourceTreeOperationsQemu(LinuxSourceTreeOperations): kconfig.merge_in_entries(base_kunitconfig) return kconfig - def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]: + def start(self, params: List[str], build_dir: str) -> subprocess.Popen: kernel_path = os.path.join(build_dir, self._kernel_path) qemu_command = ['qemu-system-' + self._qemu_arch, '-nodefaults', @@ -142,7 +142,7 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations): kconfig.merge_in_entries(base_kunitconfig) return kconfig - def start(self, params: List[str], build_dir: str) -> subprocess.Popen[str]: + def start(self, params: List[str], build_dir: str) -> subprocess.Popen: """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']) > > If so, we should revert the patch. > If not, we can undo just the Popen changes. > > And in either case, we'll need to update ./tools/testing/kunit/run_checks.py. > Currently, it runs `mypy --strict` which will start failing if we > revert any part of this patch. Those make sense. Thanks, SJ > > Thanks, > Daniel