From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 73696385842B for ; Thu, 23 Feb 2023 22:18:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73696385842B Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id F194F1E223; Thu, 23 Feb 2023 17:18:31 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/9] gdb: gdbarch.py: spell out parameters of _Component.__init__ Date: Thu, 23 Feb 2023 17:18:24 -0500 Message-Id: <20230223221830.499934-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230223221830.499934-1-simon.marchi@efficios.com> References: <20230223221830.499934-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3497.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Simon Marchi The way _Component uses kwargs is handy to save a few characters, but it doesn't play well with static analysis. When editing gdbarch.py, my editor (which uses pylance under the hood) knows nothing about the properties of components. So it's full of squiggly lines, and typing analysis (which I find really helpful) doesn't work. I therefore think it would be better to spell out the parameters. Change-Id: Iaf561beb0d0fbe170ce1c79252a291e0945e1830 --- gdb/gdbarch.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py index 68c7bbae6618..63c3aee1dc0e 100755 --- a/gdb/gdbarch.py +++ b/gdb/gdbarch.py @@ -49,9 +49,34 @@ def join_params(params): class _Component: "Base class for all components." - def __init__(self, **kwargs): - for key in kwargs: - setattr(self, key, kwargs[key]) + def __init__( + self, + name, + type, + printer, + comment=None, + predicate=False, + predefault=None, + postdefault=None, + invalid=None, + params=None, + param_checks=None, + result_checks=None, + implement=True, + ): + self.name = name + self.type = type + self.printer = printer + self.comment = comment + self.predicate = predicate + self.predefault = predefault + self.postdefault = postdefault + self.invalid = invalid + self.params = params + self.param_checks = param_checks + self.result_checks = result_checks + self.implement = implement + components.append(self) # It doesn't make sense to have a check of the result value @@ -87,7 +112,7 @@ class Value(_Component): name, type, comment=None, - predicate=None, + predicate=False, predefault=None, postdefault=None, invalid=None, @@ -115,7 +140,7 @@ class Function(_Component): type, params, comment=None, - predicate=None, + predicate=False, predefault=None, postdefault=None, invalid=None, -- 2.39.2