From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH] gdb: copyright.py cleanup
Date: Thu, 25 Apr 2024 13:38:45 -0400 [thread overview]
Message-ID: <20240425173847.50357-1-simon.marchi@efficios.com> (raw)
- 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(-)
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 <http://www.gnu.org/licenses/>.
-"""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
############################################################################
base-commit: 5b9707eb872ad4cb50c98d396d16f110070a44ca
--
2.44.0
reply other threads:[~2024-04-25 17:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240425173847.50357-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).