Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1018503rwb; Thu, 4 Aug 2022 15:43:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR7bAhqSSp5aBx//IRy3wqR3N8wZwSf+Z0KSwAK/50NQjPZzkAahgZjnp+jMBzVYFnCfqBHX X-Received: by 2002:a65:5383:0:b0:41c:1148:5d6b with SMTP id x3-20020a655383000000b0041c11485d6bmr3246127pgq.24.1659652993034; Thu, 04 Aug 2022 15:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659652993; cv=none; d=google.com; s=arc-20160816; b=HyLDi1Gmn8X1RQlBz/a0O3xTsN3iEAzJs7uvfuQveWzPiaXH3ZRcfX77R4MKS3kIC/ 5HkeugNDiJfrFLQEA2VeijT/nLrygNxsa0BefF8ispZTdzuj5siGFOLf8sTTqrRnH2Pp zRluYcKWyg4FQ4BiVy1PRvQsbp1Vow/0J/ee+wPOMcCwmA18f8/uT+P50Sh8BeOC8bmc s9CAbSHMWa4jXzfO/z2gtpJCg6is86TDdtHN7RhWFyUEiuzuP2Qeoz6IE+wDa1byf0V/ CkMlAsdlr4/2eIfhTcZBix83WUTB6dqj8ClSs6Luv2kag9avpCJXXha4a/e54jRPTgPH wc8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=FuugmUCF0TvRTU+HzlBpRf2vN7sysi6PxjIgBXMJd4Y=; b=AFFHIWCjNEd1d25jvr0/NglwMcP41tGa2++OKTYZoIfodGhJp0Rh1I752IDMG+TZdn H7+camtvgoIDWcYdYXfGLtPVuccsHF4tXhcuRHOHnJ00LURn4JcPCPodB1v/8m+15UIt Q5AnkXofRobdwnMia3rgoHdWrTCW2hVQ29AiqbAwOHNaos8de5j6wmkeTm8VdeqBqJlu 1v+g0mr9pxEaITOqbnhCaSexOQuZY/N0mwfh8yGIVlHW0WlvSKaIeRp+d9MM9e5nTUNK I1NK737lN9G1XirD/HbibuZeJhT1RRssccmAzttZMulAfq1WmfbgoSKXoZrmZCEG+IrF nYhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=l5SBZQVn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a6558c3000000b0041bc0b2cf83si1232515pgu.267.2022.08.04.15.42.58; Thu, 04 Aug 2022 15:43:13 -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=@google.com header.s=20210112 header.b=l5SBZQVn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239715AbiHDWS3 (ORCPT + 99 others); Thu, 4 Aug 2022 18:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239275AbiHDWS0 (ORCPT ); Thu, 4 Aug 2022 18:18:26 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D67476557E for ; Thu, 4 Aug 2022 15:18:25 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id x18-20020a056a000bd200b0052e70ff090dso304817pfu.18 for ; Thu, 04 Aug 2022 15:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=FuugmUCF0TvRTU+HzlBpRf2vN7sysi6PxjIgBXMJd4Y=; b=l5SBZQVnabn522EriGOrgVBqUMbRT8xQi8ySOJ9glx8sVCcnbvcUcqndcZpeLQ+zbf +xJfe7I5AHvmHn7n1eweTfR+QO6XOQbAz0nqcR5vk/7TuCW8EYPsC+TDifyQn2HxgRop WyP8zDUUK5tXAO2qulPSAB2ylG7qAN0tInXyggGgsS4/ijsZIZyn+woZDGt9iqckR6Yf bQmvCbVJNMG/Fwz1P15luRDcf7Nbxi0z5Xqpkl5/TLo2jebpgVngq017qCVIJ+2mAxN/ NZ2N0Lp8DwmKCeH5mXl8nEnTpcrrVcE8bV+ks+Qre8Sh8blqqTF9ZwMzkwrBDHNcSrHt JU3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=FuugmUCF0TvRTU+HzlBpRf2vN7sysi6PxjIgBXMJd4Y=; b=F71XQBnWGoYGsxUSy069NYyMijh7srAZgboXal6t8ZeZbICj2uxbcc0NOa2TttVxWh asjb+JPsP/4TtfVL89u+HNPz/Cu0+d3hTeIw3d6lRI0tlok5v5+SvSHrHZNgALqbL3VV CfnfOJ/l56iy8luu1zGf0XxNGCIlX+caStAoJXFclZ0quUwhgEqLdzy3yGwORj6uD3lX 9vEgQYFl5R8rK9xHY2UslbKdWKy+OTxpx0DT/u2Z9Zmw6BWDHBlzV/36oBD/JMg+7nYn ayG0fKQnGbxI3h2VjQh7cIAp/PBx8qRLsSlkBZWqEhyOrmBHz0vU69RRpbzRvT1L33Ed hDwg== X-Gm-Message-State: ACgBeo0rbW28e+n5s3D+s14mDWwvedc0MWpvPvuQ1QiSK46u2uOI0tTh yK3V5dkYtWW/adeDcuSWnp60bFdAnGm0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:f5e1:5bc5:7dab:2b7c]) (user=irogers job=sendgmr) by 2002:a05:6a00:1395:b0:52e:128a:23de with SMTP id t21-20020a056a00139500b0052e128a23demr3962734pfg.5.1659651505336; Thu, 04 Aug 2022 15:18:25 -0700 (PDT) Date: Thu, 4 Aug 2022 15:18:00 -0700 In-Reply-To: <20220804221816.1802790-1-irogers@google.com> Message-Id: <20220804221816.1802790-2-irogers@google.com> Mime-Version: 1.0 References: <20220804221816.1802790-1-irogers@google.com> X-Mailer: git-send-email 2.37.1.559.g78731f0fdb-goog Subject: [PATCH v4 01/17] perf jevents: Clean up pytype warnings From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Zhengjun Xing , Ravi Bangoria , Kan Liang , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Improve type hints to clean up pytype warnings. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/jevents.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 83e0dcbeac9a..5b72048d50da 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -6,8 +6,7 @@ import csv import json import os import sys -from typing import Callable -from typing import Sequence +from typing import (Callable, Optional, Sequence) # Global command line arguments. _args = None @@ -57,7 +56,7 @@ class JsonEvent: '. '), '.').replace('\n', '\\n').replace( '\"', '\\"').replace('\r', '\\r') - def convert_aggr_mode(aggr_mode: str) -> str: + def convert_aggr_mode(aggr_mode: str) -> Optional[str]: """Returns the aggr_mode_class enum value associated with the JSON string.""" if not aggr_mode: return None @@ -67,7 +66,7 @@ class JsonEvent: } return aggr_mode_to_enum[aggr_mode] - def lookup_msr(num: str) -> str: + def lookup_msr(num: str) -> Optional[str]: """Converts the msr number, or first in a list to the appropriate event field.""" if not num: return None @@ -79,7 +78,7 @@ class JsonEvent: } return msrmap[int(num.split(',', 1)[0], 0)] - def real_event(name: str, event: str) -> str: + def real_event(name: str, event: str) -> Optional[str]: """Convert well known event names to an event string otherwise use the event argument.""" fixed = { 'inst_retired.any': 'event=0xc0,period=2000003', @@ -95,7 +94,7 @@ class JsonEvent: return fixed[name.lower()] return event - def unit_to_pmu(unit: str) -> str: + def unit_to_pmu(unit: str) -> Optional[str]: """Convert a JSON Unit to Linux PMU name.""" if not unit: return None @@ -154,7 +153,7 @@ class JsonEvent: if self.metric_expr: self.metric_expr = self.metric_expr.replace('\\', '\\\\') arch_std = jd.get('ArchStdEvent') - if precise and self.desc and not '(Precise Event)' in self.desc: + if precise and self.desc and '(Precise Event)' not in self.desc: extra_desc += ' (Must be precise)' if precise == '2' else (' (Precise ' 'event)') event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}' -- 2.37.1.559.g78731f0fdb-goog