diff options
| author | Bob Halley <halley@dnspython.org> | 2022-03-15 08:37:20 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2022-03-15 08:37:20 -0700 |
| commit | b1d2332687adbecc0acbb4e623124f783f859d9e (patch) | |
| tree | 5318d5ecc0dd35e0a6922380cd60f9d9caa9ad34 /dns/_immutable_ctx.py | |
| parent | 08f8bde64e8679d5e4f0b129292461de152ba32b (diff) | |
| download | dnspython-b1d2332687adbecc0acbb4e623124f783f859d9e.tar.gz | |
black autoformatting
Diffstat (limited to 'dns/_immutable_ctx.py')
| -rw-r--r-- | dns/_immutable_ctx.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/dns/_immutable_ctx.py b/dns/_immutable_ctx.py index ececdbe..63c0a2d 100644 --- a/dns/_immutable_ctx.py +++ b/dns/_immutable_ctx.py @@ -8,7 +8,7 @@ import contextvars import inspect -_in__init__ = contextvars.ContextVar('_immutable_in__init__', default=False) +_in__init__ = contextvars.ContextVar("_immutable_in__init__", default=False) class _Immutable: @@ -41,6 +41,7 @@ def _immutable_init(f): f(*args, **kwargs) finally: _in__init__.reset(previous) + nf.__signature__ = inspect.signature(f) return nf @@ -50,7 +51,7 @@ def immutable(cls): # Some ancestor already has the mixin, so just make sure we keep # following the __init__ protocol. cls.__init__ = _immutable_init(cls.__init__) - if hasattr(cls, '__setstate__'): + if hasattr(cls, "__setstate__"): cls.__setstate__ = _immutable_init(cls.__setstate__) ncls = cls else: @@ -63,7 +64,8 @@ def immutable(cls): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - if hasattr(cls, '__setstate__'): + if hasattr(cls, "__setstate__"): + @_immutable_init def __setstate__(self, *args, **kwargs): super().__setstate__(*args, **kwargs) |
