]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
copy the signature of __init__ too
authorBob Halley <halley@dnspython.org>
Fri, 14 Aug 2020 00:52:49 +0000 (17:52 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 14 Aug 2020 00:52:49 +0000 (17:52 -0700)
dns/_immutable_attr.py
dns/_immutable_ctx.py

index bf8aebc560148a803f38088a19736c7bd683564d..f7b9f8b0b7a48e46e4e3cbcbaab4eeb3c61fa1e5 100644 (file)
@@ -4,6 +4,10 @@
 # which doesn't have Context Variables.  This implementation is somewhat
 # costly for classes with slots, as it adds a __dict__ to them.
 
+
+import inspect
+
+
 class _Immutable:
     """Immutable mixin class"""
 
@@ -48,6 +52,7 @@ def _immutable_init(f):
                 # If we started the initialzation, establish immutability
                 # by removing the attribute that allows mutation
                 object.__delattr__(args[0], '_immutable_init')
+    nf.__signature__ = inspect.signature(f)
     return nf
 
 
index 400ab6ce167e9bddea88b350ebee26c6d7805af7..ececdbeb48ab319aa2a8a0820c8aa1fd1a1fbf93 100644 (file)
@@ -5,6 +5,8 @@
 # with slots immutable.  It's also faster.
 
 import contextvars
+import inspect
+
 
 _in__init__ = contextvars.ContextVar('_immutable_in__init__', default=False)
 
@@ -39,6 +41,7 @@ def _immutable_init(f):
             f(*args, **kwargs)
         finally:
             _in__init__.reset(previous)
+    nf.__signature__ = inspect.signature(f)
     return nf