From patchwork Thu Apr 25 17:38:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 89002 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 3DD3C384AB55 for ; Thu, 25 Apr 2024 17:39:19 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 746403858C66 for ; Thu, 25 Apr 2024 17:38:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 746403858C66 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 746403858C66 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=1714066730; cv=none; b=ZRsrLbF0ruyNmim+0z1ovtFFnPca44Qz5hMrqy9i5vDYnfj2j4QPt4JtY5HzlovZ4EJ5nqK2eBmmpxI0mzFqR936v8i+RW3HamNUOMXjnLhCIKbJ8l+FtsqGPtsKUkUZJvAqRGvc8YX1kaYxUof3lZEDd7aWmHxWwUxfqlWxWn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714066730; c=relaxed/simple; bh=46Ok3bh13MNebtjexRbC53c7GA87zXsljgrqm0Z34sI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AjCFglY4u9YqS/l9BqKT4SIGwlaF4Cu6S8ZrnyI1sglN60UKLGQ+S32SEC0p/yBAO+IL9+7smgz5lqI7qgOrC0NHqzlwciw+OFm0rwqj6DyaIxBXQ7JjpXR98/DV6yzi9oSGPS1iPzJtZ5cUApn7/6orzSfB8LHh/6uF7Dm17Gw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (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 042CC1E092; Thu, 25 Apr 2024 13:38:47 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: copyright.py cleanup Date: Thu, 25 Apr 2024 13:38:45 -0400 Message-ID: <20240425173847.50357-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3496.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_SHORT, 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 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+patchwork=sourceware.org@sourceware.org - Make the top comment a proper comment instead of a string, to avoid "invalid escape sequence" warnings due to `\*`. - Remove `datetime` import. - Add type annotations. Use `type: ignore` comments in some places to work around the fact that `BY_HAND` has an "empty tuple" type. Change-Id: I5c2444b794b1138c7760ec5a221f298a8b43f7d4 --- gdb/copyright.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) base-commit: 5b9707eb872ad4cb50c98d396d16f110070a44ca diff --git a/gdb/copyright.py b/gdb/copyright.py index 2c9ea3c1d591..74d5cb9994d9 100755 --- a/gdb/copyright.py +++ b/gdb/copyright.py @@ -17,21 +17,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -"""copyright.py - -This script updates the list of years in the copyright notices in -most files maintained by the GDB project. - -Usage: cd src/gdb && ./copyright.py - -Always review the output of this script before committing it! -A useful command to review the output is: - % filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff -This removes the bulk of the changes which are most likely to be correct. -""" +# This script updates the list of years in the copyright notices in +# most files maintained by the GDB project. +# +# Usage: cd src/gdb && ./copyright.py +# +# Always review the output of this script before committing it! +# A useful command to review the output is: +# % filterdiff -x \*.c -x \*.cc -x \*.h -x \*.exp updates.diff +# This removes the bulk of the changes which are most likely to be correct. import argparse -import datetime import locale import os import os.path @@ -40,14 +36,14 @@ import sys from typing import List, Optional -def get_update_list(): +def get_update_list() -> list[str]: """Return the list of files to update. Assumes that the current working directory when called is the root of the GDB source tree (NOT the gdb/ subdirectory!). The names of the files are relative to that root directory. """ - result = [] + result: list[str] = [] for gdb_dir in ( "gdb", "gdbserver", @@ -63,7 +59,8 @@ def get_update_list(): dirname in EXCLUDE_ALL_LIST or reldirname in EXCLUDE_LIST or reldirname in NOT_FSF_LIST - or reldirname in BY_HAND + # Use `type: ignore` to avoid an `always evaluate to False` warning + or reldirname in BY_HAND # type: ignore ): # Prune this directory from our search list. dirs.remove(dirname) @@ -73,7 +70,7 @@ def get_update_list(): filename in EXCLUDE_ALL_LIST or relpath in EXCLUDE_LIST or relpath in NOT_FSF_LIST - or relpath in BY_HAND + or relpath in BY_HAND # type: ignore ): # Ignore this file. pass @@ -82,7 +79,7 @@ def get_update_list(): return result -def update_files(update_list): +def update_files(update_list: list[str]): """Update the copyright header of the files in the given list. We use gnulib's update-copyright script for that. @@ -127,7 +124,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. @@ -197,8 +194,8 @@ def main(argv: List[str]) -> Optional[int]: print( "\033[31mREMINDER: The following files must be updated by hand." "\033[0m" ) - for filename in BY_HAND: - print(" ", filename) + for filename in BY_HAND: # type: ignore + print(" ", filename) # type: ignore ############################################################################