[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Dennis Sweeney
Dennis Sweeney added the comment: > other attributes will not be copied The signature of wraps() is wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',)) Passing the updated=() will prevent the __dict__ from being update

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Erez Zinman
Erez Zinman added the comment: This is an interoperability bug. Maybe not a severe one (due to the workaround), but it's still a bug. -- ___ Python tracker ___ __

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Erez Zinman
Erez Zinman added the comment: I haven't because I don't need it anymore and it will surely work. Yet by doing so, other attributes will not be copied. I think that the `abc`-related attributes are irrelevant regardless, and should be omitted (at least by default). -- _

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Dennis Sweeney
Dennis Sweeney added the comment: Did you try adding updated=()? @functools.wraps(_internal_main_operation, updated=()) def external_main_operation(self, *args, **kwargs): -- ___ Python tracker

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-22 Thread Erez Zinman
Erez Zinman 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):

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-13 Thread Dennis Sweeney
Dennis Sweeney added the comment: > the ABC wouldn't have any abstract methods, I was wrong about this since the @abstractmethod decorator adds 'f' to the __abstractmethods__ set of the ABC, but the rest of my comment stands. -- ___ Python tracker

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-13 Thread Dennis Sweeney
Dennis Sweeney added the comment: I don't think changing @wraps is what you want. Even if you manually set `wrapper.__isabstractmethod__ = False`, you won't reach `print('f is called!')`, since f() is overridden by the child. And if you do that, the ABC wouldn't have any abstract methods, si

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-03-13 Thread Kamil Turek
Change by Kamil Turek : -- nosy: +kamilturek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue43010] @functools.wraps and abc.abstractmethod interoperability

2021-01-23 Thread Erez Zinman
New submission from Erez Zinman : Consider the following code: ``` from abc import ABC, abstractmethod from functools import wraps class A(ABC): @abstractmethod def f(self): pass @wraps(f) def wrapper(self): print('f is called!') f() class