]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Don't use mutable default arguments.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 14 Apr 2024 01:51:06 +0000 (18:51 -0700)
committerBruno Haible <bruno@clisp.org>
Sun, 14 Apr 2024 06:10:50 +0000 (08:10 +0200)
* pygnulib/GLFileSystem.py (GLFileAssistant.__init__): Set the default
argument for 'transformers' to None. If it is None then set it to an
empty dictionary in the body.

ChangeLog
pygnulib/GLFileSystem.py

index f57cb59b812331b1d1ad89e5b886ad69d97aad8b..4333a003a50f0aef9e22bb49f65ccbd2790adc2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-14  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Don't use mutable default arguments.
+       * pygnulib/GLFileSystem.py (GLFileAssistant.__init__): Set the default
+       argument for 'transformers' to None. If it is None then set it to an
+       empty dictionary in the body.
+
 2024-04-13  Bruno Haible  <bruno@clisp.org>
 
        bootstrap: Implement phase 1 as documented in the --help output.
index ee78181d8239b03a9cc62a6a6d3a290423b92590..4bd8b1f386783d34e051c0de4af5920a616dcaa2 100644 (file)
@@ -154,7 +154,7 @@ class GLFileSystem:
 class GLFileAssistant:
     '''GLFileAssistant is used to help with file processing.'''
 
-    def __init__(self, config: GLConfig, transformers: dict[str, tuple[re.Pattern, str] | None] = dict()) -> None:
+    def __init__(self, config: GLConfig, transformers: dict[str, tuple[re.Pattern, str] | None] | None = None) -> None:
         '''Create GLFileAssistant instance.
 
         config stores information shared between classes.
@@ -164,7 +164,9 @@ class GLFileAssistant:
         if type(config) is not GLConfig:
             raise TypeError('config must be a GLConfig, not %s'
                             % type(config).__name__)
-        if type(transformers) is not dict:
+        if transformers == None:
+            transformers = dict()
+        elif type(transformers) is not dict:
             raise TypeError('transformers must be a dict, not %s'
                             % type(transformers).__name__)
         for key in ['lib', 'aux', 'main', 'tests']: