summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-08-13 17:52:49 -0700
committerBob Halley <halley@dnspython.org>2020-08-13 17:52:49 -0700
commited752aa8a20bf4d494c8736b168345d233ed46bf (patch)
tree8a26f9c6b310705d5a32bee9f683b426d825e119
parentb5f5facc465c2fde5361b27dad0dbf88c26a0603 (diff)
downloaddnspython-ed752aa8a20bf4d494c8736b168345d233ed46bf.tar.gz
copy the signature of __init__ too
-rw-r--r--dns/_immutable_attr.py5
-rw-r--r--dns/_immutable_ctx.py3
2 files changed, 8 insertions, 0 deletions
diff --git a/dns/_immutable_attr.py b/dns/_immutable_attr.py
index bf8aebc..f7b9f8b 100644
--- a/dns/_immutable_attr.py
+++ b/dns/_immutable_attr.py
@@ -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
diff --git a/dns/_immutable_ctx.py b/dns/_immutable_ctx.py
index 400ab6c..ececdbe 100644
--- a/dns/_immutable_ctx.py
+++ b/dns/_immutable_ctx.py
@@ -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