Closed plammens closed 3 years ago
Interesting, this is related to discussion #12. If relying on the magic namespace lookup is the preferred style, then it could be argued this should raise an error. Whereas if one's planning on using register
, then it should definitely behave like any Python object.
Either way, this is an improvement. Thanks.
If relying on the magic namespace lookup is the preferred style, then it could be argued this should raise an error.
I agree, but then, even if one is strictly using register
only, the first function (decorated with @multimethod
) would raise an error if the name was already present in the namespace (with an unrelated value), since this logic is in __new__
; so the register
way would have to be aware of the magic namespace lookup way, so to speak. But maybe this is also desirable behaviour.
This fixes an issue where a new multimethod whose name collides with an unrelated variable or function in the same namespace would return that as the result of the decoration.