Forgot to add _replace() method to new Options class

This commit is contained in:
Kovid Goyal 2018-04-01 12:33:18 +05:30
parent 910cebeeb5
commit 43ce3ce4b0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -90,7 +90,12 @@ def create_options_class(keys):
def _asdict(self):
return {k: getattr(self, k) for k in self._fields}
ans = type('Options', (), {'__slots__': slots, '__init__': __init__, '_asdict': _asdict})
def _replace(self, **kw):
ans = self._asdict()
ans.update(kw)
return self.__class__(ans)
ans = type('Options', (), {'__slots__': slots, '__init__': __init__, '_asdict': _asdict, '_replace': _replace})
ans._fields = keys
return ans