GrahamDumpleton / wrapt

A Python module for decorators, wrappers and monkey patching.
BSD 2-Clause "Simplified" License
2.06k stars 231 forks source link

Add ClassProxy #126

Closed rominf closed 3 years ago

coveralls commented 6 years ago

Coverage Status

Coverage increased (+1.4%) to 93.895% when pulling 0197ea50443722c9aa40b7e8abd24bd5ef780fc3 on rominf:class-wrapper into 9c9ee09599957c0ef889e7cd5aacb79f7954c81e on GrahamDumpleton:develop.

GrahamDumpleton commented 6 years ago

Can you explain the use case for this with examples. I can't see why something line this needs to be a part of wrapt itself.

rominf commented 6 years ago

Sure. See module-wrapper library: https://github.com/rominf/module-wrapper/blob/master/module_wrapper/__init__.py#L56. This library recursively wraps modules, wrapping all callables to wrapper. I needed ClassProxy class to wrap other classes. If I used inheritance, and wrapped class instance executed some method in the method, called by the user, wrapped class would execute method from wrapper class, not from wrapped class. I couldn't use ObjectProxy, because I needed to wrap class, but not objects.

jayvdb commented 4 years ago

Needs docs and/or tests.

jayvdb commented 4 years ago

https://github.com/herczy/class_proxy is quite a good example of what I would expect from a class proxy, as is predecessor https://github.com/zyga/padme

GrahamDumpleton commented 3 years ago

Going to close this PR out. The utility of this was never really clear and not something that arises enough to be included in a generic package.