On 4/19/24 10:07 AM, Bruno Haible wrote:
> Yeah, it seems redundant. You will surely find out whether doing so
> triggers some warnings from pylint, PyCharm, or other tools...

What do you think of the attached patch?

I tried to find out more about these variables but they are only
mentioned briefly in PEP 8 [1]. It looks like they are old variables
predating all of the fancy Python packaging stuff [2].

I've just removed the copies from constants.py and unused definitions
in the rest of the *.py files. In GLInfo we use __author__ and
__copyright__ for '--version' and copyright headers on generated
Makefiles, m4 files, etc. For that we can use:

    from pygnulib import __author__, __copyright__

to get them from __init__.py.

I would just leave the rest of the definitions in __init__.py too. If
in the distant future there is ever a need to package gnulib-tool.py
so you can do something like:

    $ pip install pygnulib
    $ python3 -m pygnulib --create-testdir

that information is pretty much copy-pasted into the configuration
files. I don't see much use for them beyond that though.

[1] https://peps.python.org/pep-0008/#module-level-dunder-names
[2] https://stackoverflow.com/a/9531279/23476799

Collin
From 5468442826688f02b778b8fddbc4850255838c6e Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Fri, 19 Apr 2024 23:42:24 -0700
Subject: [PATCH] gnulib-tool.py: Remove duplicate per-module definitions.

* pygnulib/constants.py: Remove duplicate __authors__, __license__, and
__copyright__ definitions.
* pygnulib/GLInfo.py: Use the value of __authors__ and __copyright__
from __init__.py for output.
* pygnulib/*.py: Remove unused references to the constant.py
definitions.
---
 ChangeLog                   | 10 ++++++++++
 pygnulib/GLConfig.py        |  8 --------
 pygnulib/GLEmiter.py        |  8 --------
 pygnulib/GLError.py         |  8 --------
 pygnulib/GLFileSystem.py    |  8 --------
 pygnulib/GLImport.py        |  8 --------
 pygnulib/GLInfo.py          | 11 ++---------
 pygnulib/GLMakefileTable.py |  8 --------
 pygnulib/GLModuleSystem.py  |  8 --------
 pygnulib/GLTestDir.py       |  8 --------
 pygnulib/constants.py       | 10 ----------
 11 files changed, 12 insertions(+), 83 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1af6861244..b565a68faf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-04-19  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Remove duplicate per-module definitions.
+	* pygnulib/constants.py: Remove duplicate __authors__, __license__, and
+	__copyright__ definitions.
+	* pygnulib/GLInfo.py: Use the value of __authors__ and __copyright__
+	from __init__.py for output.
+	* pygnulib/*.py: Remove unused references to the constant.py
+	definitions.
+
 2024-04-19  Bruno Haible  <br...@clisp.org>
 
 	wcsstr: Update doc.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 9a4f4bfe68..19611b823c 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -27,14 +27,6 @@
 from pygnulib.enums import CopyAction
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index ff4e3027d6..91077a0325 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -30,14 +30,6 @@
 from .GLMakefileTable import GLMakefileTable
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py
index a990c382b1..47d1e97fdc 100644
--- a/pygnulib/GLError.py
+++ b/pygnulib/GLError.py
@@ -22,14 +22,6 @@
 from . import constants
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index 4bd8b1f386..1cad7f5bad 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -28,14 +28,6 @@
 from .GLConfig import GLConfig
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index b38808a353..eb937755ae 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -32,14 +32,6 @@
 from .GLEmiter import GLEmiter
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index c7de90376a..37d8560af0 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -21,17 +21,10 @@
 import os
 import re
 import subprocess as sp
+from pygnulib import __author__, __copyright__
 from . import constants
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
@@ -125,7 +118,7 @@ def date(self) -> str:
 
     def copyright_range(self) -> str:
         '''Returns a formatted copyright string showing a year range.'''
-        return f'Copyright (C) {constants.__copyright__}'
+        return f'Copyright (C) {__copyright__}'
 
     def usage(self) -> str:
         '''Show help message.'''
diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py
index 8df0822f00..a38276c665 100644
--- a/pygnulib/GLMakefileTable.py
+++ b/pygnulib/GLMakefileTable.py
@@ -23,14 +23,6 @@
 from .GLConfig import GLConfig
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 6d5e874375..301592a79d 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -30,14 +30,6 @@
 from .GLFileSystem import GLFileSystem
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 38427e402e..6ec925ac37 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -35,14 +35,6 @@
 from .GLEmiter import GLEmiter
 
 
-#===============================================================================
-# Define module information
-#===============================================================================
-__author__ = constants.__author__
-__license__ = constants.__license__
-__copyright__ = constants.__copyright__
-
-
 #===============================================================================
 # Define global constants
 #===============================================================================
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 0b6a606a01..4890e2129f 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -34,16 +34,6 @@
 # Define module information
 #===============================================================================
 __all__ = []
-__author__ = \
-    [
-        'Bruno Haible',
-        'Paul Eggert',
-        'Simon Josefsson',
-        'Dmitry Selyutin',
-        'Collin Funk',
-    ]
-__license__ = 'GNU GPLv3+'
-__copyright__ = '2002-2024 Free Software Foundation, Inc.'
 
 
 #===============================================================================
-- 
2.44.0

Reply via email to