From: Collin Funk Date: Sun, 14 Apr 2024 01:51:06 +0000 (-0700) Subject: gnulib-tool.py: Don't use mutable default arguments. X-Git-Tag: v1.0~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f67b0b14ddaeed38b23c7db035eb4d0b38b56a12;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index f57cb59b81..4333a003a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-04-14 Collin Funk + + 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 bootstrap: Implement phase 1 as documented in the --help output. diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py index ee78181d82..4bd8b1f386 100644 --- a/pygnulib/GLFileSystem.py +++ b/pygnulib/GLFileSystem.py @@ -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']: