From patchwork Mon Feb 27 01:13:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 65658 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B276D3858D39 for ; Mon, 27 Feb 2023 01:15:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B276D3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677460502; bh=Y7vkW5iG8sMPOh3Mfs0oYJ5vF3elMqXris65bi/ddAw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=evd0mg1Oih6lRQMwKMPY9wZZUsSNBD85ON6/0MNR/qxpPtYpWY1I0Lf3LdwWwFvCP fmTnh0UVEABPb+Y+dPh/pLRlVGTKYZ2boUJpBO8JnzgHeiVOp7DspFBTm0uH9l4YfI 5TU4vdHVNnetz9yvDcJCvhNTX6TXEKEW9XG3Sy/Y= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 1C2CA3858D32 for ; Mon, 27 Feb 2023 01:14:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C2CA3858D32 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 31R1E6V5026121 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 26 Feb 2023 20:14:10 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 31R1E6V5026121 Received: from simark.localdomain (unknown [217.28.27.60]) (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 AA4101E223; Sun, 26 Feb 2023 20:14:05 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi , Tom Tromey Subject: [PATCH v3 03/10] gdb: gdbarch.py: spell out parameters of _Component.__init__ Date: Sun, 26 Feb 2023 20:13:56 -0500 Message-Id: <20230227011403.612304-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227011403.612304-1-simon.marchi@polymtl.ca> References: <20230227011403.612304-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 27 Feb 2023 01:14:06 +0000 X-Spam-Status: No, score=-3189.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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 Reviewed-By: Tom Tromey --- 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,