Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5147561pxj; Tue, 22 Jun 2021 16:31:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxd1Zes8ksgV30phOpxaj3Jg9B8HOYs9fqrg3171YXCFWGzr3zT6mDbNHEAezbvP0/lDNQ X-Received: by 2002:a17:906:fa04:: with SMTP id lo4mr6852008ejb.162.1624404673912; Tue, 22 Jun 2021 16:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624404673; cv=none; d=google.com; s=arc-20160816; b=Uul+sEQf45ku+ioLSioKfiwiN8Zxw5dk4C9xl4XRi6L+HlYSubuIhhYmFeY9X9qlQ+ O8xK23L/FOsEk3foSKK080YMo2iVp5BvTjodYkO6i85TPc18BCfQU+UVHp7tt4R5s3zv Ng2qCxvkRGzzDywrBjRrnUu2mz60bVtoqQPR6nE3MpYOgmu8XflWdf17eK25D/I1TBP0 Jh1U7QiSMmtWVwUyZKX+6KdAj+ZIGNqlpDCdG5zAZTGiQGeIj1T+ovaoywdCQaPvHCD6 gTJcBAZF/d5a5NQAPzaFnPq6kN6cxaKYZFOaj9XO+7gZ3l79mkDl8cEUxquQIi9smcbu ErSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=BPkqmTODcvr4WgFhtXMV/bmKQtzCPSOCAM1LvuXyGzk=; b=D81dvFLnwKqBKFKzbrjhXmgyCw7UhIcS0CSuiylpwSxFIDjO4sJZ9sgSofkDzw2BlP Pr+EThzt0NnKdVlmEZPld6LSzY/+GvcxEuzq00l2LyLYL2FH1O8yj5hRuLxdFRdHW7sf rvkLPulFKBECsYuTTry63u+T3pCUuiao5uyfNJ4H24u2s26N736vlAYtw/La76MX7WVD ptztL5TKyfpoaLCf8dlTvUP5t5BD+0wEAToiqMW02SLrfo5cIdiT5ep4FCPzXeWBvZjn p5Buc47Q259bovYETe6AcKXXhfwZ+7BPAmpXBRcaS5mrlMcvMBmtQ5bh5fDfI5cO0FjD dKnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YO7c5TAa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si17617015ejk.224.2021.06.22.16.30.50; Tue, 22 Jun 2021 16:31:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YO7c5TAa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbhFVXbE (ORCPT + 99 others); Tue, 22 Jun 2021 19:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFVXbE (ORCPT ); Tue, 22 Jun 2021 19:31:04 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08518C061756 for ; Tue, 22 Jun 2021 16:28:47 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id a6so1232080ioe.0 for ; Tue, 22 Jun 2021 16:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BPkqmTODcvr4WgFhtXMV/bmKQtzCPSOCAM1LvuXyGzk=; b=YO7c5TAaCCqEuN7liNrVb7535wuDyHh9HyLjpzAmgohl8XMPL6t0tYIj9kM+x6+aU5 p+KcSx2cvKS714uc9vbJpcGpLhf/DIUjmPFzeFoWE5T0j73vaBlFwb7UzF3MyeKRGbNE Bo6vGFotf935bp+brvd0+fSloz20P3/oiRBrFlQqUMJLQiCTeRDXe4oI6FaMpqZpI1+B PipCMqI9pSGAF27kjAduurWT+Nxtybbh07bs4YTV0Uawnd/ubjogggBehxmI/TGwF6Mf uimddpvRmPZA6GKh2u2rfVKlpORkfJ8yFCsNgzjSJXo3hyw6h9lJwPcv735uLBnYBpbo ETFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BPkqmTODcvr4WgFhtXMV/bmKQtzCPSOCAM1LvuXyGzk=; b=syxKsr7ceEHPDwHNgCOOVpQWyGO5ofTppZIa2GJ8qbGHN4SIRAkJAZaGOc4v4jk1hc kLOydOQAXsHLomI15+oAeh53zdB21P4YLNq+Dh5GTFm7irinU09HwAo24Ap6zJJgglXU yx3lmhDZnxK8HabLhDHqfePCDWQp2MkUad94WUxA/YS69v79WfYi0SyIcXvHbTPJy3/D bXJPVzSi4bzphYxPnp3f2iLijesqC47qJ7EzJ0iw7DASX1xO6oSyVigfHPla/TQthMDK YKsdvXPDbbgcps3cpqQo9R8ccyqYUizoH0rxpqIQJjQIwO/zmHlqgst4XznTy3bVrSEe aXKA== X-Gm-Message-State: AOAM532ttwLUxKnC4hUgYTKx859k+taPjGoLWjFpR9+p7mTCi8BkHtfv zyogG2llRF2c4pnTzjdRvxXd6O1UB5zz1rEQ5pu76g== X-Received: by 2002:a5d:9d55:: with SMTP id k21mr4649098iok.57.1624404526263; Tue, 22 Jun 2021 16:28:46 -0700 (PDT) MIME-Version: 1.0 References: <20210617073937.16281-1-sjpark@amazon.de> <20210617074638.16583-1-sjpark@amazon.de> In-Reply-To: <20210617074638.16583-1-sjpark@amazon.de> From: Daniel Latypov Date: Tue, 22 Jun 2021 16:28:34 -0700 Message-ID: Subject: Re: [PATCH v2] kunit: tool: Assert the version requirement To: SeongJae Park Cc: brendanhiggins@google.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, SeongJae Park Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 17, 2021 at 12:46 AM SeongJae Park wrote: > > Commit 87c9c1631788 ("kunit: tool: add support for QEMU") on the 'next' > tree adds 'from __future__ import annotations' in 'kunit_kernel.py'. > Because it is supported on only >=3.7 Python, people using older Python > will get below error: > > Traceback (most recent call last): > File "./tools/testing/kunit/kunit.py", line 20, in > import kunit_kernel > File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 9 > from __future__ import annotations Chatted offline with David about this. He was thinking if we could instead drop the minimal version back to 3.6. I think we can do so, see below. Perhaps we should drop the import and then chain this patch on top of that, specifying a minimum version of 3.6? Checking out https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/?h=kunit-fixes The offending "annotations" import is related to type annotations. Specifically https://www.python.org/dev/peps/pep-0563/ So let's see how the two most popular typecheckers fare. pytype is happy with or without import. mypy has the same issues with or without the import. $ mypy tools/testing/kunit/*.py tools/testing/kunit/kunit_kernel.py:227: error: Item "_Loader" of "Optional[_Loader]" has no attribute "exec_module" tools/testing/kunit/kunit_kernel.py:227: error: Item "None" of "Optional[_Loader]" has no attribute "exec_module" tools/testing/kunit/kunit_kernel.py:228: error: Module has no attribute "QEMU_ARCH" tools/testing/kunit/kunit_kernel.py:229: error: Module has no attribute "QEMU_ARCH" So clearly it's not doing anything for them. Taking a look over 87c9c1631788 ("kunit: tool: add support for QEMU") next then... I don't see anything that would warrant the import, so we should probably drop it. In that case, the minimum supported version should drop back down to 3.6. We use enum.auto, which is from 3.6 https://docs.python.org/3/library/enum.html#enum.auto We could consider stopping using that, and I think we might be then 3.5-compatible. Maybe we have a chain of 3 patches then, drop the import, drop auto, and then add in a >=3.5 version check? > ^ > SyntaxError: future feature annotations is not defined > > This commit adds a version assertion in 'kunit.py', so that people get > more explicit error message like below: > > Traceback (most recent call last): > File "./tools/testing/kunit/kunit.py", line 15, in > assert sys.version_info >= (3, 7), "Python version is too old" > AssertionError: Python version is too old > > Signed-off-by: SeongJae Park > Acked-by: Daniel Latypov > --- > > Changes from v1 > - Add assertion failure message (Daniel Latypov) > - Add Acked-by: Daniel Latypov > > tools/testing/kunit/kunit.py | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py > index be8d8d4a4e08..6276ce0c0196 100755 > --- a/tools/testing/kunit/kunit.py > +++ b/tools/testing/kunit/kunit.py > @@ -12,6 +12,8 @@ import sys > import os > import time > > +assert sys.version_info >= (3, 7), "Python version is too old" > + > from collections import namedtuple > from enum import Enum, auto > > -- > 2.17.1 >