-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
HasProperties.__init__ takes arbitrary key word arguments and assigns them to existing properties. However, it also has a strange behaviour: if the kwarg is not a property but is an existing attribute -
properties/properties/base/base.py
Line 313 in 6daa40a
| if not prop and not hasattr(self, key): |
properties/properties/base/base.py
Line 324 in 6daa40a
| setattr(self, key, val) |
__init__ raises an AttributeError - properties/properties/base/base.py
Line 314 in 6daa40a
| raise AttributeError( |
For example, this errors:
class MyClass(properties.HasProperties):
pass
MyClass(some_function=0)But this doesn't...
class MyClass(properties.HasProperties):
def some_function(self):
...
MyClass(some_function=0)This isn't a huge deal; I mean, you can override any attribute once the object is created. It's just super strange that __init__ allows this implicitly.
Reactions are currently unavailable