Erez Zinman <erezinman.program...@gmail.com> added the comment:
Sorry for the late response. I forgot about that. I believe one of us misunderstands the problem. The problem is that `functools.wraps` copies the `__isabstractmethod__` in the first place. Consider the following example: ``` class ModuleTemplate(ABC): @abstractmethod def _internal_main_operation(self, a: int, b: str, c: list) -> bool: pass @functools.wraps(_internal_main_operation) def external_main_operation(self, *args, **kwargs): print('LOG: Operation started.') try: ret = self._internal_main_operation(*args, **kwargs) except: print('LOG: Operation finished successfully.') raise else: print('LOG: Operation finished successfully.') return ret class ModulePositiveCheck(ModuleTemplate): def _internal_main_operation(self, a: int, b: str, c: list) -> bool: return a > 0 ``` In that case, I have a class that has a main operation that can be called either from the outside or internally. The outside call may be wrapped with some aspect-specific functionality like thread-safety, logging, exception handling, etc.; and the internal call implements the core logic of the class. In that (pretty common) pattern, I wouldn't want the `wraps` function to copy all the `abc` attributes because they're irrelevant. In fact, I'm having trouble thinking of a case where you WOULD like these attributes to be copied. The solution here, I think, is to exclude these attributes from being copied within `functools.update_wrapper`. If you do want to allow copying these attributes (I don't see why, but anyway), you could add an `excluded` parameter to `update_wrapper`. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43010> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com