From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KEVgKEaJ9mf8Ai0AWB0awg (envelope-from ) for ; Wed, 09 Apr 2025 10:50:46 -0400 Received: by simark.ca (Postfix, from userid 112) id 94B5B1E0C3; Wed, 9 Apr 2025 10:50:46 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2E0B81E05C for ; Wed, 9 Apr 2025 10:50:46 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BACC384A454 for ; Wed, 9 Apr 2025 14:50:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BACC384A454 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A95773857C67 for ; Wed, 9 Apr 2025 14:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A95773857C67 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A95773857C67 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744210204; cv=none; b=H/AW77vzQsBaPGSBRNyblvQsHrhuFFH/P3PzC6tz52++uLiDvJ7RSqeiw855psteBR+PNU2zEgY78kyE3dvfVaHfy7Ls1Yi1hiN/x8V/w7LwH9LXdufUdok8QEtDXFA0ab74gs+TV4Q0d+2TTDD/ymiGSmeA0/3fJdH5N+vWGGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744210204; c=relaxed/simple; bh=6ZUpa+eAaXlZ9hQ+BpeQD+/obZke63I9sknIXxYeTOM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=O2M88DMj+C+ahQtG8W6sZGF6svFG2EvWuoH2NB3zhSkGUqXbHo1N4vEFmxN5H+9/FDc4RDunMgXhVXJ5rGlTPkGitcifHH6HuFl5EBLVSmQJhaPPeLxCoM/CWNWNnUcJ2vWZ7hR44f3+HsWdobtouEKSXQxGQG2XYQQwCHQc+N0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A95773857C67 Received: by simark.ca (Postfix, from userid 112) id 67A3E1E100; Wed, 9 Apr 2025 10:50:04 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 8E3011E05C; Wed, 9 Apr 2025 10:50:03 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb: make typing strict in gdb/copyright.py Date: Wed, 9 Apr 2025 10:49:58 -0400 Message-ID: <20250409145002.30405-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Add `pyright: strict` at the top of the file, then adjust the fallouts. This annotation is understood by pyright, and thus any IDE using pyright behind the scenes (VSCode and probably others). I presume that any GDB developer running this script is using a recent enough version of Python, so specify the type annotations using the actual types when possible (e.g. `list[str]` instead of `typing.List[str]`). I believe this required Python 3.9. Change-Id: I3698e28555e236a03126d4cd010dae4b5647ce48 --- gdb/copyright.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gdb/copyright.py b/gdb/copyright.py index 5ec9944aae20..1c81358f1384 100755 --- a/gdb/copyright.py +++ b/gdb/copyright.py @@ -30,13 +30,15 @@ # # This removes the bulk of the changes which are most likely to be correct. +# pyright: strict + import argparse import locale import os import os.path import subprocess import sys -from typing import List, Optional +from typing import Iterable def get_update_list(): @@ -66,7 +68,7 @@ def get_update_list(): .split("\0") ) - def include_file(filename): + def include_file(filename: str): (dirname, basename) = os.path.split(filename) dirbasename = os.path.basename(dirname) return not ( @@ -83,7 +85,7 @@ def get_update_list(): return filter(include_file, result) -def update_files(update_list): +def update_files(update_list: Iterable[str]): """Update the copyright header of the files in the given list. We use gnulib's update-copyright script for that. @@ -128,7 +130,7 @@ def update_files(update_list): print("*** " + line) -def may_have_copyright_notice(filename): +def may_have_copyright_notice(filename: str): """Check that the given file does not seem to have a copyright notice. The filename is relative to the root directory. @@ -166,7 +168,7 @@ def get_parser() -> argparse.ArgumentParser: return parser -def main(argv: List[str]) -> Optional[int]: +def main(argv: list[str]) -> int | None: """The main subprogram.""" parser = get_parser() _ = parser.parse_args(argv) @@ -242,9 +244,9 @@ EXCLUDE_ALL_LIST = ( ) # The list of files to update by hand. -BY_HAND = ( +BY_HAND: list[str] = [ # Nothing at the moment :-). -) +] # Files containing multiple copyright headers. This script is only # fixing the first one it finds, so we need to finish the update base-commit: 2bbe439e72916c7d61bf0b7a8c898426bfabc0ba -- 2.49.0