Skip to content

Commit

Permalink
pass *args to __new__
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Feb 17, 2016
1 parent f458645 commit 90dac53
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions traitlets/traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,14 @@ class HasDescriptors(py3compat.with_metaclass(MetaHasDescriptors, object)):
"""The base class for all classes that have descriptors.
"""

def __new__(cls, *args, **kw):
def __new__(cls, *args, **kwargs):
# This is needed because object.__new__ only accepts
# the cls argument.
new_meth = super(HasDescriptors, cls).__new__
if new_meth is object.__new__:
inst = new_meth(cls)
else:
inst = new_meth(cls, **kw)
inst = new_meth(cls, *args, **kwargs)
inst.setup_instance()
return inst

Expand Down Expand Up @@ -936,12 +936,12 @@ def setup_instance(self):
self._trait_validators = {}
super(HasTraits, self).setup_instance()

def __init__(self, *args, **kw):
def __init__(self, *args, **kwargs):
# Allow trait values to be set using keyword arguments.
# We need to use setattr for this to trigger validation and
# notifications.
with self.hold_trait_notifications():
for key, value in iteritems(kw):
for key, value in iteritems(kwargs):
setattr(self, key, value)

def __getstate__(self):
Expand Down

0 comments on commit 90dac53

Please sign in to comment.